PDA

View Full Version : opening a new window from within nested iframes



fulcrum
Mar 21st, 2003, 12:55 AM
Hi, I have a question that should not be very complicated but I have not been able to find a solution to for some time.

Basically, I have the following page structure:

iframe 1
-------------------------------------
| iframe 2 |
| |
| <link> |
| |
|------------------------------------|
| iframe 3 |
| |
|------------------------------------|

What I would like to be able to do is open a new window from the link in iframe2, where the window does not have any toolbars and addressbars.

I have tried the usual window.open and parent.window.open but I am not getting the object hiearchy correctly and everything results in the new page opening withing iframe2

Any advise will be appreciated?

cheesebagpipe
Mar 21st, 2003, 12:59 AM
Doesn't sound like a 'hierarchy' problem; window.open() should open a window, period, without reference to where it's called from. Show us what you're doing. ;)

fulcrum
Mar 21st, 2003, 01:09 AM
This is the entire page that loads into <iframe2>:

<html>
<link rel="stylesheet" type="text/css" href="/stylesheets//default/gallery.css" />

<style>
body { background-image: url(/images//pictures/personal/backxPkb75.jpg); background-repeat: no-repeat; background-attachment: fixed;
background-position: 0 0; margin: 0 0 0 0px; padding: 0 0 0 0px; }
div#comment { background-image: url(/images//pictures/personal/backMD99EH.jpg); background-repeat: no-repeat; background-attachment: fixed;
background-position: 0 0; margin: 10pt 0pt 0pt 10pt; width: 90%; padding: 2pt 10pt 5pt 2pt; border-width: 1px 1px 1px 1px;
border-color: black; border-style: solid; }
</style>

<body>
<script language="JavaScript">
function show () {
window.open('http://myhost.com/pictures/personal/img20030313122542.jpg', 'image', 'fullscreen=no,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=yes,directories=no,location= no,width=800,height=600');
}
</script>
<div id="comment">
<a href="#" onClick="show()"><img src="/images/cats/full.gif" border=0></a>
<p>Some comment</p>
</div>
</body>

</html>

cheesebagpipe
Mar 21st, 2003, 01:15 AM
Try this:

<body>
<script language="JavaScript">
function show () {
window.open('http://www.google.com', 'image', 'width=800,height=600,scrollbars,resizable');
return false;
}
</script>
<div id="comment">
<a href="#" onClick="return show()"><img src="/images/cats/full.gif" border=0></a>
<p>Some comment</p>
</div>
</body>

Make sure window.open(.....); is all on one line; this editor totally destroys it, for some reason...

glenngv
Mar 21st, 2003, 01:27 AM
maybe the problem is the target you use in window.open:

window.open('http://myhost.com/pictures/personal/img20030313122542.jpg', 'image', '...');

maybe the name of iframe2 is 'image'. try using a different target that does not exist or use '_blank' instead.

fulcrum
Mar 21st, 2003, 01:32 AM
Originally posted by glenngv
maybe the problem is the target you use in window.open:

window.open('http://myhost.com/pictures/personal/img20030313122542.jpg', 'image', '...');

maybe the name of iframe2 is 'image'. try using a different target that does not exist or use '_blank' instead.


That was it!! The name of iframe2 was in fact image. When I change the new window's name, everything started working.

Thanx for all your help!!