View Full Version : want to open window from within frame
tpeck
12-27-2002, 08:41 AM
Hi. I have this code to open a new window to fullwindow size. It works well when the page containing the code is alone, but it doesn't open the new window when the page containing the code is a frame page. I can't work out why... (the script is cut down a bit):
************************************
<head>
<script language="javascript">
<!-- Begin
function full(){
window.open('newpage.html','fullwindow','toolbar=no,fullscreen=no,location=no,directories=no,status= no,menubar=no,scrollbars=no,resizable=yes');
}
// End -->
</script>
</head>
<body>
<map name="FPMap0">
<area href="javascript:full();return false" shape="circle" coords="402, 65, 52">
</map>
<img border="0" src="images/picture.gif" usemap="#FPMap0" width="500" height="348>
</body>
************************************
If anyone can throw some light on what I am doing wrong, I would appreciate it.
Thanks.
Terry
Algorithm
12-27-2002, 09:20 AM
Instead of window.open, try top.window.open. Unless the frame page is on a different server than the source page, that should work.
tpeck
12-27-2002, 09:59 AM
Thanks - I tried it, but no success I'm afraid.
It's all on the same server and the link to the new window just happens to be a hotspot on a graphic. It could be a button, I suppose, but it wouldn't change anything.
There must be a simple answer like 'top' but I've tried 'parent'. 'body' etc. - everything I can think of!
My javascript new windows coding is pretty poor ...
Terry
duniyadnd
12-27-2002, 10:48 AM
Hmmmm... it should work automatically though.
Try the following changes:
<area href="javascript:full();return false" shape="circle" coords="402, 65, 52">
becomes
<area href="#" onClick="full();" shape="circle" coords="402,65,52">
as for the javascript code, the window.open code looks correct, though i've never heard of a "fullscreen" attribute, you might want to remove that, and instead, put in specified height and width attributes if you wish.
Also, make sure that none of the frames have been given the name fullwindow.
Let me know if it works.
Duniyadnd
tpeck
12-27-2002, 11:04 AM
It worked!
So now the (basic) code is:
***************************
<head>
<script language="javascript">
<!-- Begin
function full(){
top.window.open('newpage.html','fullwindow','toolbar=no,location=no,directories=no,status=no,menubar =no,scrollbars=no,resizable=yes');
}
// End -->
</script>
</head>
<body>
<map name="FPMap0">
<area href="#" onClick="full();" shape="circle" coords="402,65,52">
</body>
************************************
I took out the fullscreen attribute and added the 'top' before the window, just to be sure, although it worked without the 'top'.
Thanks people for your help - it is sure appreciated.
Terry
duniyadnd
12-27-2002, 11:10 AM
that's great
just curious though, did you ever try removing the "return false" from your original code? maybe it was that that didn't allow you to open a new window.
Duniyadnd
tpeck
12-27-2002, 11:25 AM
I tried so many combinations of things - I can't be sure, but I seem to remember adding the 'return false' idea to see if it made it work, but it didn't, so I must have started out without the 'return false'. I therefore don't think it made any difference.
I've noticed one other small problem I've got to solve though - the "#" part of the coding causes the original page containing the link (within frames) to become the only page showing. I'd like that not to happen.
Anyone caring to see this in action can visit:
http://www.aapress.com.au/tests.html
Click on the link on the graphic.
Thanks all.
Terry
duniyadnd
12-27-2002, 11:57 AM
not really a mistake, but not what you wanted in the end.
in your "aboutmain" file
remove the following line:
<base target="_top">
that should fix it.
duniyadnd
tpeck
12-27-2002, 12:13 PM
Yes, that fixes the 'page that remains behind problem'.
I must work out the reasoning behind the whole thing tomorrow, but it works and that's the main thing!
I am indebted to you.
Many thanks,
Terry
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.