Forum Moderators: open
function moreInfo(val1,val2,val3,val4){
var windowWidth="width=";
var windowHeight="height=";
var comma=",";
var quote="'";
var windowAttr=",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no";
var attributes=quote.concat(windowWidth).concat(val3).concat(comma).concat(windowHeight).
concat(val4).concat(comma).concat(windowAttr).concat(quote);
window.open(val1,val2,attributes);
}
[edited by: whoisgregg at 7:24 pm (utc) on June 3, 2009]
[edit reason] fixed sidescroll. :) [/edit]
Try
attributes=quote.concat(windowWidth, val3, comma, windowHeight, val4, comma, windowAttr, quote);
From some reason the width attribute is not being set when the window is opened
Is there a reason you're using concat?
Also, you don't need "yes" "no" "1" or "0" for window attributes; just include them if you want them, leave them out if you don't. It might even be this that's giving you the grief.
Second, the first parameter, window name, is meant to be a unique id. If you just pass "windowname" to it every time, visualize this scenario:
User clicks link, window opens.
User clicks back to main window.
User clicks another link, and the content *DOES* load in the already-open window.
But since the already open window is BEHIND the main window, their impression? Your site is broken.
For that reason I've eliminated "val1" and set the ID using a time method, which guarantees the content will *always* open in a new window (if it's not blocked.) Along the same line of thinking, it's always good to use variables that describe what they do instead of anonymous arbitrary names - hence val2=url, val3=w(idth), val4=h(eight).
Simplifying your code might make life easier . . . see if this works.
function moreInfo(url,w,h){
var day=new Date();
var id=day.getTime();
var attributes='width='+w+',height='+h;
//Leaving off resizable and scrollbars is a *really bad idea.*
//You never know your user's environment. So you might want this instead:
//var attributes='width='+w+',height='+h+',resizable,scrollbars';
window.open(id,url,attributes);
}