Jump to content

Please help me on; Error: iframe is not defined at...

Recommended Posts

I tried to insert an element into iframe so first I must retrieve it by

var frm = document.querySelectorAll(iframe)

but cannot work.


ReferenceError: iframe is not defined at Object.callback...

How to succeed to insertion as easily as other ordinary elements? thank so much.

Edited by abdu
Link to post
Share on other sites

You have to pass a string, which is delimited by either single quotes or double quotes.

var frm = document.querySelectorAll("iframe");

If all you're looking for is a list of iframe elements, you don't need the querySelectorAll method, getElementsByTagName will work just as well.

var frm = document.getElementsByTagName("iframe");


Link to post
Share on other sites

That means that there are no iframes in your document. The might be because you're running the code before the iframes have loaded. Try putting this Javascript at the bottom of your HTML document after everything has finished loading.

Link to post
Share on other sites

Or, if you use jQuery you can wrap your code in the $(document).ready() { ... }; function.  In this way, the Javascript will not be run until the full document has been loaded.


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...