Popup window placement with V5

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
donbmjr
Advanced
Advanced
Posts: 11
Joined: Tue Oct 07, 2003 10:33 pm

Popup window placement with V5

Post by donbmjr »

In v3 I would call up a script to open a popup window (Milonic script) with the addition of this line var from_left = screen.width / 2 - the_width / 2; the windows would center on the screen at the top (or I could adjust the amount they came down from the top. In v5 like v3 the windows open in some random fashion around the page, what can be done to center these windows in v5.
The site below is still using v3, if you go to the menu on the left and down to Standings and make a selection you will see what I am looking for.

Thanks

Don miller

http://www.theinsidegroove.com/

function openNewWindow(winURL,winWidth,winHeight,winConfig)
{
var mmConfig = '\
width=' + winWidth + ',\
height=' + winHeight + ',\
left=' + (screen.width / 2 - winWidth / 2) + ',\
' + winConfig
var mmWin = window.open(winURL,'',mmConfig);
mmWin.focus();
}
function n_window(theurl)
{
// set the width and height
var the_width=675;
var the_height=575;
// set window position
var from_top=0;
var from_left = screen.width / 2 - the_width / 2;
// set other attributes
var has_toolbar='yes';
var has_location='yes';
var has_directories='no';
var has_status='no';
var has_menubar='yes';
var has_scrollbars='yes';
var is_resizable='yes';
// attributes put together
var the_atts='width='+the_width+',height='+the_height+',top='+from_top+',screenY='+from_top+',left='+from_left+',screenX='+from_left;
the_atts+=',toolbar='+has_toolbar+',location='+has_location+',directories='+has_directories+',status='+has_status;
the_atts+=',menubar='+has_menubar+',scrollbars='+has_scrollbars+',resizable='+is_resizable;
// open window
window.open(theurl,'',the_atts);
}





http://www.theinsidegroove.com/
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi Don,

This issue is really independent of the menu system, v3 or v5. The openNewWindow() function is simply a javascript function to open a page in a new window. The old Milonic site (and maybe the current one) supplied such a script as an example, but there are many such examples on the web. The modifications to the original openNewWindow() function, as it appeared on the Milonic site, were made to automatically control the horizontal position of the window... again, there are many such examples on the web.

In v3 or v5, if you open a new window simply by specifying target=_new or target=_blank (as I suspect you must be trying now), then the new window will take on the parent window's properties (toolbar, scrollbars, etc.) and will be positioned by the OS... which in Windows typically means slightly below and to the right of where the last window opened. That's why they seem to "appear all over the place".

What can you do? That's the good part! Use the same exact openNewWindow() function that you have now. For example, what you have in your old menu:

Code: Select all

,"Winston Cup Standings","javascript:openNewWindow(\"pop/standings.php4\",746,540,\"top=0,status=yes,resizable=yes,scrollbars=yes\")",,,0
would become:

Code: Select all

aI("text=Winston Cup Standings;url=javascript:openNewWindow('pop/standings.php4',746,540,'top=0,status=yes,resizable=yes,scrollbars=yes');");
Note that I replaced the escaped double quotes in the function call (\") with single quotes ('). You should be able to use the escaped doubles if you want to.

Nice looking site by the way.

Hope that helps,

Kevin
donbmjr
Advanced
Advanced
Posts: 11
Joined: Tue Oct 07, 2003 10:33 pm

Works Great

Post by donbmjr »

Thanks Kevin
Everything worker out great.
Another week and we will debut this site

Thanks again

Don Miller
User avatar
fredlongworthhighschool
Mega Advanced
Mega Advanced
Posts: 362
Joined: Fri Jun 27, 2003 11:34 am
Location: Manchester, England.
Contact:

Post by fredlongworthhighschool »

I use this system if it's of any use to you:

http://www.sitepoint.com/article/1022
Andy Davis
Web Designer & Smartboard Manager

Fred Longworth High School, Manchester, England.
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

The Milonic DHTML Menu also includes this functionality out of the box. If you look at sample 11 http://milonic.com/menusample.php?sampleid=11 you will see that there is a property called targetfeatures that allows you to make a popup window automatically and also set its properties, all within a single menu item. Give it a try.
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hergio wrote:The Milonic DHTML Menu also includes this functionality out of the box...
Yep... targetfeatures is definitely a nice touch in the menu system, but I thought It'd be better for Don to stick with his current approach, since he wanted the new window to automatically center and already had functions to do that. The targetfeatures property only seems to let you open a new window at the origin... it doesn't explicitly allow control over left/top (IE) screenX/screenY (ns)... perhaps because of the different naming convention between browsers??? Anyway, from the little that I've played with it, it seems like the new window will always open at 0,0. I don't know if this is forced by the menu system or what, and haven't gone digging to find out. Any light to shed on this Dave?

Now that I'm playing with it, I notice that top and left attributes do seem to work in IE, but if I recall correctly, those window.open() attrs are only recognized by IE. My tests in NS7 are all messed up! In NS7, I can only get the first attribute to work, and then it's only some of them. For example, height works, but only if it's the first in the list. Same with width. But every other attribute after the first is ignored. Other attributes don't seem to want to work no matter where they are in the list: resizable, scollbars, status... I thought that maybe the menu item syntax was changed so that it should be a comma-separated list, like you would normally use for window.open(), but no dice there. Have you tried these features in various browsers? Am I batty... well... that's too broad of a question... let me rephrase... Am I missing something?

One other thing to note: None of the examples on the Sample 11 page actually uses the targetfeatures property. E.g., the "Contact Us - 300 by 300 Window" doesn't actually have any targetfeatures set... all it does is open a new window with target=_blank. So I don't have any examples to go by. Maybe this property isn't completed yet???

Any insights?

Kevin
donbmjr
Advanced
Advanced
Posts: 11
Joined: Tue Oct 07, 2003 10:33 pm

Thanks Again

Post by donbmjr »

Nice helpfull group
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

You're welcome. Glad we could be of service. ;) Enjoy your Milonic DHTML Menu.
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
Post Reply