What's new

Html onclick iframe video

Bl4ckC4p_03

Eternal Poster
Established
Joined
Aug 28, 2017
Posts
1,088
Solutions
1
Reaction
630
Points
504
Age
22
Anong mali po dito sa code? Gusto ko kasi gumawa ng onclick iframe na pwede ma full screen yung video sa loob ng site.


<button onclick="openIframe()">Open Iframe</button>

<script>
function openIframe() {
var iframe = document.createElement('iframe');
iframe.width = '560';
iframe.height = '315';
iframe.src = 'You do not have permission to view the full content of this post. Log in or register now.
iframe.allowfullscreen = true;

var button = document.querySelector('button');
button.parentNode.replaceChild(iframe, button);
}
</script>


Di kasi nya nag fufull screen kahit iclick ko yung full screen eh, pero pag normal iframe lang na naka allowfullscreen gumagana naman
 
Sa iyong code, mayroong ilang mga mali. Tingnan natin ang mga ito:

1. Ang iyong URL sa loob ng iframe.src ay hindi tamang format. Kailangan mong tanggalin ang mga [URL] at [/URL] tags. Ang tamang format ay:

JavaScript:
iframe.src = 'https://anix.to/home';

2. Ang iframe.allowfullscreen ay hindi isang direktang attribute ng isang iframe element. Kailangan mong gamitin ang setAttribute function upang itakda ang allowfullscreen attribute. Narito ang naayos na code:

JavaScript:
function openIframe() {
  var iframe = document.createElement('iframe');
  iframe.width = '560';
  iframe.height = '315';
  iframe.src = 'https://anix.to/home';
  iframe.setAttribute('allowfullscreen', true);
  
  var button = document.querySelector('button');
  button.parentNode.replaceChild(iframe, button);
}

3. Siguraduhin mong ang iyong script ay nasa tamang lugar sa iyong HTML code. Dapat ito ay nasa ibaba ng <button> element, o kahit saan basta't ito ay nasa loob ng <body> tag.

Dapat ay maayos na gumagana ang iyong code upang maipakita ang iframe at mabigyan ng kakayahan ang video na maging fullscreen.
 
Sa iyong code, mayroong ilang mga mali. Tingnan natin ang mga ito:

1. Ang iyong URL sa loob ng iframe.src ay hindi tamang format. Kailangan mong tanggalin ang mga [URL] at [/URL] tags. Ang tamang format ay:

JavaScript:
iframe.src = 'https://anix.to/home';

2. Ang iframe.allowfullscreen ay hindi isang direktang attribute ng isang iframe element. Kailangan mong gamitin ang setAttribute function upang itakda ang allowfullscreen attribute. Narito ang naayos na code:

JavaScript:
function openIframe() {
  var iframe = document.createElement('iframe');
  iframe.width = '560';
  iframe.height = '315';
  iframe.src = 'https://anix.to/home';
  iframe.setAttribute('allowfullscreen', true);
 
  var button = document.querySelector('button');
  button.parentNode.replaceChild(iframe, button);
}

3. Siguraduhin mong ang iyong script ay nasa tamang lugar sa iyong HTML code. Dapat ito ay nasa ibaba ng <button> element, o kahit saan basta't ito ay nasa loob ng <body> tag.

Dapat ay maayos na gumagana ang iyong code upang maipakita ang iframe at mabigyan ng kakayahan ang video na maging fullscreen.
Talino mo, gumana nga
 
Talino mo, gumana nga
Salamat! Natutuwa akong malaman na gumana na ang iyong code. Kung mayroon ka pang ibang mga tanong o mga pangangailangan sa coding, huwag kang mag-atubiling magtanong muli. Ako ay nandito upang tulungan ka. Magpatuloy sa iyong paglalakbay sa pagpoprograma!
 
Ewan pero medyo creepy talaga ang AI natin dito sa PHCorner. Hahahahahaha




"Life is TOUGH but I don't give a shit because I know I am AWESOME"
꧁•⊹٭𝚂𝚘𝚞𝚕 𝙲𝚊𝚕𝚒𝚋𝚛𝚎٭⊹•꧂
𝐍𝐀𝐓𝐒𝐔
 
Ewan pero medyo creepy talaga ang AI natin dito sa PHCorner. Hahahahahaha




"Life is TOUGH but I don't give a shit because I know I am AWESOME"

꧁•⊹٭𝚂𝚘𝚞𝚕 𝙲𝚊𝚕𝚒𝚋𝚛𝚎٭⊹•꧂

𝐍𝐀𝐓𝐒𝐔
Tinanong ko muna yung sa open ai, pero nung tinest ko hindi parin gumana kaya nag tanong na ako dito, ayon alam pala ni phcrobot, si phc robot yata pinakamatalinong robot e hahah
 
Tinanong ko muna yung sa open ai, pero nung tinest ko hindi parin gumana kaya nag tanong na ako dito, ayon alam pala ni phcrobot, si phc robot yata pinakamatalinong robot e hahah
Ang knowledge bank ata ng PHC Robot at combined info dito sa thread at sa developers ng site kaya ganyan.. minsan medyo creepy nga lang talaga. hehehehe




"Life is TOUGH but I don't give a shit because I know I am AWESOME"
꧁•⊹٭𝚂𝚘𝚞𝚕 𝙲𝚊𝚕𝚒𝚋𝚛𝚎٭⊹•꧂
𝐍𝐀𝐓𝐒𝐔
 

Similar threads

Back
Top