PDA

View Full Version : iframes and using window.open


rubixD
10-09-2002, 10:50 AM
I have a page setup with photos inside of an iframe. When someone clicks on the a photo it opens a new window, also (this is where my problem lies) when they click on the photo it scrolls the iframe back to the top, I was wondering if there was a simple way to correct this.

This is the script to open the new window itself iside the iframe:

<script language="javascript">

var image

function loadPhotowindow(image)
{
var s1="<title>"+image+"</title>"
var s2="<body bgcolor=black leftmargin=0 topmargin=5 marginwidth=0 marginheight=0><center>"
var s3="<img src='"+image+"' border=0>"
var s4="<br>"
var s5="<form><input type='button' value='close' onClick='self.close()'>"
var s6="</form></center>"

photoWindow=window.open("", 'rubixPhotos', config='height=540, width=650, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no')
photoWindow.document.write(s1+s2+s3+s4+s5+s6)
photoWindow.document.close()
}
</script>

..and here is the script for the iframe itself inside a table data cell:

<td width=564>
<iframe src="begin.html" height="100%" width="100%" frameborder=0 name="main"></iframe>
</td>

adios
10-09-2002, 04:54 PM
You left out a key item: how is the function loadPhotowindow called? OK - I'll take a wild guess....um, like this?

<a href="#" onclick="loadPhotowindow()">.....</a>

If so - go:

<a href="#" onclick="loadPhotowindow();return false;">.....</a>

Common error, forgetting to kill the loading of that '#' (top of page anchor).

If that's not it, let's see some more of that <iframe> doc....

rubixD
10-09-2002, 08:47 PM
thanks adios! That worked :)

actually its called by loadPhotowindow('location of image')

but anyway, thats so simple it makes sense :P never thought of it before..