Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IFrame Not Recognized..... 2

Status
Not open for further replies.

TomTT

Programmer
Jun 3, 2002
55
US
I'm trying to set the src for an IFrame in javascript, but keep getting the error 'document.form1.Fram1' is null or not an object.

The following code is being used. It works fine for Img tags and images, but blows up when I try to access the IFrame. What am I missing?

Any suggestions would be greatly appreciated.

TT

<HEAD>
<Script Language=&quot;javascript&quot;>
function DoText(){document.form1.Fram1.src=&quot;Text/Pig.htm&quot;;}
</Script>

</HEAD>

<BODY onLoad=&quot;DoText()&quot;>
<Form Name=&quot;form1&quot; ID=&quot;frm1&quot;>
<IFrame Name=&quot;Fram1&quot; ID=&quot;Fram1&quot;></IFrame>
</Form>
</BODY>
 
Try document.Fram1 - the <iframe> tag is not part of a form object. If that doesn't work, try window.Fram1, but I doubt that's it. ________________________________________
Michael C Flanakin
Indigo Web Systems
michael.flanakin@indigows.com
 
Thanks for the quick response. I tried both document.Fram1 and window.Fram1 but no luck. I know the path is correct since if I set the src in the IFrame tag it pulls the correct page.

Any other ideas?

TT
 
Oh, duh...try this:

var frmWindow = document.getElementById('Fram1');
frmWindow.src = 'whatever.html';

That will only work in IE, tho. What I suggest is you start with this:

alert(document.Fram1);

If you get a popup that says &quot;object&quot; then you're on the right track. If not, you need to get there (obviously). I'm sorry I can't be of more help, but I'm dead tired, right now. Hopefully the getElementById() will help you out some. Good luck. ________________________________________
Michael C Flanakin
Indigo Web Systems
michael.flanakin@indigows.com
 
You have to use an ordinary frame referencing in a frameset.

If it is a reference from one frame to another in the same frameset it should be this:
[tt]parent.frameName.location.href = url;[/tt]

If it is a reference to some frame in another window (i.e. in another frameset) it should be this:
[tt]windowName.frameName.location.href = url;[/tt]
 
Thanks to ciddivine and starway. Both approaches worked!

TT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top