PDA

View Full Version : Control size of window



jjvoice
05-07-2006, 01:26 PM
Hi,
I have one of the older navigation systems installed. It has the option of specifying a target window to open your link in. I can use "_blank" to get the link to open in a new window, but is there any way to set the size of the window that opens? Thanks.

jjvoice

Twey
05-07-2006, 01:43 PM
Depends how old a browser we're talking here :)
You need to use Javascript. The best way to do it is:
<a href="page.html" target="_blank" onclick="window.open(this.href, '', 'width=400,height=400');return false;">Link Text</a>I wouldn't advise setting a size bigger than 640x480.

jjvoice
05-07-2006, 02:21 PM
Hi,

Thanks for the reply. I know how to do this if I was coding it myself. The problem is that you have to use the custom.js file of the script to set your links. Here is the line for setting up a sub-menu item:

addSubmenuItem("url","\title","_blank","");

I can put "_blank" in the third parameter and it opens in a new window, but I see no way of setting the size of the window that opens. I got thi script from DynamicDrive a number of years ago and no longer have the documentation and don't see it on their page anymore. Was just wondering if someone had any ideas that would work. Thanks.

jjvoice

Twey
05-07-2006, 02:30 PM
Unfortunately, without the full code, I can't help you. If the script is that old, it's likely that there's a newer replacement available on DD.

jscheuer1
05-07-2006, 08:03 PM
This looks like a variation on HV Menu (http://www.dynamicdrive.com/dynamicindex1/hvmenu/index.htm) or Jim's DHTML Menu v5.7 (http://www.dynamicdrive.com/dynamicindex1/jimmenu/index.htm), either of which can now accept:


addSubmenuItem("javascript:window.open('http://www.google.com', '_blank', 'width=400,height=400');","\title","","");

in their link or url field.

Your script may not in fact be one that can do this but, many of these type menu scripts have this capability built in. If this won't work for yours, consider trying one of the above linked menus that your code resembles.

jjvoice
05-12-2006, 09:02 PM
John,

Thanks for the reply. I tried that and it worked great, except for one problem. It did open the window with the size I specified, but instead of just leaving the original page as is, where I could close the new window and be on the original page, it opened the new window, and changed the original page to a blank page with just "[object]" in the upper lefthand corner of the page. Any idea why that happened? Thanks.

Bob

Twey
05-12-2006, 09:09 PM
Any idea why that happened?The page is displaying the return value of the window.open() call. Try:
javascript:void(window.open('http://www.google.com', '_blank', 'width=400,height=400'));

jjvoice
05-12-2006, 09:58 PM
John,

That worked great! Thanks!

Bob

Twey
05-12-2006, 10:19 PM
I'm not John. :)

jjvoice
05-13-2006, 01:18 AM
Twey,

Oops, sorry - looked to fast - thought it was John responding again. Thanks, Twey - it worked great!

Bob

jscheuer1
05-13-2006, 06:46 AM
Yes, thanks Twey. The menus I mentioned have handlers that do that or similar for you with URLS that begin with 'javascript:'