Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:01
Popup window placement with V5
Poster: donbmjr
Dated: Friday October 24 2003 - 22:30:31 BST
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/
Poster: kevin3442
Dated: Friday October 24 2003 - 23:47:46 BST
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:
,"Winston Cup Standings","javascript:openNewWindow(\"pop/standings.php4\",746,540,\"top=0,status=yes,resizable=yes,scrollbars=yes\")",,,0
would become:
Code:
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
Works Great
Poster: donbmjr
Dated: Saturday October 25 2003 - 1:27:35 BST
Thanks Kevin
Everything worker out great.
Another week and we will debut this site
Thanks again
Don Miller
Poster: fredlongworthhighschool
Dated: Monday October 27 2003 - 8:37:57 GMT
I use this system if it's of any use to you:
http://www.sitepoint.com/article/1022
Poster: Hergio
Dated: Monday October 27 2003 - 18:41:28 GMT
The Milonic DHTML Menu also includes this functionality out of the box. If you look at sample 11 http://www.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.
Poster: kevin3442
Dated: Tuesday October 28 2003 - 1:41:42 GMT
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