Click to See Complete Forum and Search --> : open html doc in same page?
BabyJenk5
09-14-2003, 12:59 AM
how would I write an external javascript file so that i can open an html document in the parent page (a frame-like effect)? for example, if i click on a link in the parent page, the document will load into that same page, in a specified location. i haven't been able to find any tutorials on how to do this. any help would be appreciated. thanks!
Beach Bum
09-14-2003, 01:44 AM
I think you may want an iframe. This will put a frame inside a page.
<iframe src="xxx.htm" width=" " height=" " name="iframe1" frameborder="0"></iframe>
then change the frame with JS like this:
window.frames['iframe1'].location.href = "yyyy.htm";
Charles
09-14-2003, 07:16 AM
There's no need to use icky JavaScript to load something in that IFRAME. And if you do use JavaScript it will fail for 13% of users. Just use the "target" attribute with the A element.
<a href="http://www.w3.org/" target="iframe1">W3C</a>
Beach Bum
09-14-2003, 10:29 AM
Originally posted by Charles
There's no need to use icky JavaScript to load something in that IFRAME. And if you do use JavaScript it will fail for 13% of users. Just use the "target" attribute with the A element.
<a href="http://www.w3.org/" target="iframe1">W3C</a>
That is half of the question . . . now how do you change the contents of the iframe from a link without using javascript?
Enselic
09-14-2003, 11:26 AM
you set the target attribute to the name of your iframe.
Charles
09-14-2003, 12:23 PM
Originally posted by Enselic
you set the target attribute to the name of your iframe. As does my example above.. Note, we were given the name of the iframe, "iframe1", in the original plea.
Beach Bum
09-14-2003, 12:27 PM
Oh yes . . . I see. Duh . . . Good solution.
bhollin
09-18-2003, 01:28 PM
I need to do something similar, but within an onClick event.
I've tried:
<a onClick="window.frames['frame1'].location.href="newurl";" href=""><img src="foo.gif">
</a>
<iFrame
width="400" height="300" src="initial url" name="frame1" border="0" bordercolor="#ffffff" hspace="0" vspace="0" marginwidth="0" marginheight="0" scrolling="auto" frameborder="no">
</iFrame>
but no luck.
The reason I can't sue a simple
<a href="newurl" target="frame1"></a>
is that the href in this table cell is already taken up by a image swap function.
i.e., I need to be able to click a button that swaps an image in one table cell and swaps an html document in an iframe at the same time.
Any suggestions would be much appreciated!