Created
July 28, 2011 16:57
-
-
Save rwaldron/1111943 to your computer and use it in GitHub Desktop.
Get the document of an iframe element
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var iframe = document.getElementById("my-iframe"), | |
iframeDoc = ( iframe.contentWindow || iframe.contentDocument ).document; | |
console.log( iframeDoc ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get the value of the data-videoid attribute in the iframe element using JavaScript, you can use the following code:
// get iframe element using its id
var iframe = document.getElementById("your-iframe-id");
// get the value of the data-videoid attribute
var dataVideoid = iframe.getAttribute("data-videoid");
// do something with the data-videoid value
console.log(dataVideoid);
Replace your-iframe-id with the actual id of the iframe in your page. This code will retrieve the iframe element using its id and then use the getAttribute() method to retrieve the value of the data-videoid attribute. You can then use this value as needed in your code