471,071 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

Can't create a handle to an iframe.

Daz
Hi everyone.

I am trying to create a handle to an iframe, but the script only gets
to a certain point and then fails. I am new to JavaScript, and I have
tried everything I can think of, but I just can't seem to figure it
out.

Below is the script with some comments so you can see what's happening.

var tmp_id = document.getElementById("BROWSER");
// tmp_id = [object HTMLIFrameElement]

var f_browser = tmp_id.contentDocument;
// f_browser = [object HTMLDocument]

f_browser = f_browser.contentWindow.document;
// f_browser = undefined

Could anyone explain what I am doing wrong. I have used this method
after seeing several examples online, although to be honest, I don't
understand what it's doing (or not doing) 100%.

Any help would be appreciated.

Nov 4 '06 #1
4 3919
Daz wrote:
I am trying to create a handle to an iframe, but the script only gets
to a certain point and then fails. I am new to JavaScript, and I have
tried everything I can think of, but I just can't seem to figure it
out.
Use e.g.
<iframe name="iframeName" src="whatever.html" ...></iframe>
in your HTML markup then from the document containing that iframe you
can script e.g.
var iframe = window.frames.iframeName;
or
var iframe = window.frames['iframeName'];
then (if you still want to care about Netscape 4 which does not support
iframes) you check e.g.
if (iframe) {
// now decide what you want to use,
// iframe is the iframe window object
// iframe.document the document in the iframe
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Nov 4 '06 #2
Daz

Martin Honnen wrote:
Daz wrote:
I am trying to create a handle to an iframe, but the script only gets
to a certain point and then fails. I am new to JavaScript, and I have
tried everything I can think of, but I just can't seem to figure it
out.

Use e.g.
<iframe name="iframeName" src="whatever.html" ...></iframe>
in your HTML markup then from the document containing that iframe you
can script e.g.
var iframe = window.frames.iframeName;
or
var iframe = window.frames['iframeName'];
then (if you still want to care about Netscape 4 which does not support
iframes) you check e.g.
if (iframe) {
// now decide what you want to use,
// iframe is the iframe window object
// iframe.document the document in the iframe
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Martin,

Many thanks. You made everything sound so much simpler than I was
actually making it. Your method works great, and has saved me a lot
more head scratching and yelling abusive obscenities at my computer
monitor.

All the best.

Daz.

Nov 4 '06 #3
Daz

Daz wrote:
Hi everyone.

I am trying to create a handle to an iframe, but the script only gets
to a certain point and then fails. I am new to JavaScript, and I have
tried everything I can think of, but I just can't seem to figure it
out.

Below is the script with some comments so you can see what's happening.

var tmp_id = document.getElementById("BROWSER");
// tmp_id = [object HTMLIFrameElement]

var f_browser = tmp_id.contentDocument;
// f_browser = [object HTMLDocument]

f_browser = f_browser.contentWindow.document;
// f_browser = undefined

Could anyone explain what I am doing wrong. I have used this method
after seeing several examples online, although to be honest, I don't
understand what it's doing (or not doing) 100%.

Any help would be appreciated.
Hi. I have one more problem. The browser doesn't apear to stop loading
the page. Is there any way I can close the open handle, on the code
above?

Nov 4 '06 #4
Daz

Daz wrote:
Daz wrote:
Hi everyone.

I am trying to create a handle to an iframe, but the script only gets
to a certain point and then fails. I am new to JavaScript, and I have
tried everything I can think of, but I just can't seem to figure it
out.

Below is the script with some comments so you can see what's happening.

var tmp_id = document.getElementById("BROWSER");
// tmp_id = [object HTMLIFrameElement]

var f_browser = tmp_id.contentDocument;
// f_browser = [object HTMLDocument]

f_browser = f_browser.contentWindow.document;
// f_browser = undefined

Could anyone explain what I am doing wrong. I have used this method
after seeing several examples online, although to be honest, I don't
understand what it's doing (or not doing) 100%.

Any help would be appreciated.

Hi. I have one more problem. The browser doesn't apear to stop loading
the page. Is there any way I can close the open handle, on the code
above?
f_browser.document.close();

Sorted! :)

Nov 4 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Troy | last post: by
5 posts views Thread by Reply Via Newsgroup | last post: by
5 posts views Thread by Angel | last post: by
6 posts views Thread by Andrew | last post: by
7 posts views Thread by pb | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.