473,473 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 4010
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Troy | last post by:
Hello- I have a website that uses a custom built webserver to serve the pages. (Please don't ask me why my boss had his own web server written). I am displaying a log of information that is an...
2
by: Csaba2000 | last post by:
I want to be able to embed a single quote into an INPUT element within a dynamically generated IFRAME. The example below shows how the IFRAME is generated. Challenge: I'd like the alert box to...
5
by: Reply Via Newsgroup | last post by:
Folks, I am specifically using an IFRAME but am also interested if this is possible via a window opened using window.open Basically - I have a popup window that I use for uploads - When an...
5
by: Angel | last post by:
Is there a way to create an IFRAME dynamically via VB.NET. In other words creating the HTML element in the server side code? thanks in advance....
6
by: Andrew | last post by:
Hello, friends, I developed a web page with the following statement as part of it: <td width="80%" height="800" valign="top"> <iframe width="100%" height="100%"...
1
by: pbd22 | last post by:
hi. i have been posting this here and elsewhere a lot and can't seem to get resolution on this problem. i have been trying to upload files using a hidden iframe to a asp.net/vb.net form. the...
7
by: pb | last post by:
Hi all, I have some code that automatically generates a url depending on user selections. This url is then set as a hyperlink and the user clicks on the link that has the target as an iframe on...
7
Ferris
by: Ferris | last post by:
Hi I wonder how to create a 0-border iframe with javascript,here's my code,it works in firefox,but not in IE. <div id="testdiv"></div> <script language="javascript"> var iframe =...
4
by: zion4ever | last post by:
Hello good people, Please bear with me as this is my first post and I am relative new to ASP. I do have VB6 experience. I have a form which enables users within our company to do an intranet...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.