Jump to content

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


abdu

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.

Quote

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 comment
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 comment
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 comment
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.

Roddy

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...