Okay, I rejigged my code about and now of course it does not work:
function popupCenter(pageURL, title, w, h) {
var left = (screen.width / 2) - (w / 2);
window.open(pageURL, title, 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width=' + w + ',height=' + h + ',top=' + top + ',left=' + left);
}
function dimension_test() {
var width = window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth; switch (width) {
case 1024:
popupCenter('http://www.meta.projectmio.com/index.html', 'MyWindow', 1024, 699);
break;
case 800:
popupCenter('http://www.meta.projectmio.com/800.html', 'MyWindow', 800, 531);
break;
case 640:
popupCenter('http://www.meta.projectmio.com/640.html', 'MyWindow', 640, 411);
break;
}
}
My first concerns lie with the “case” e.g. “case 640”; does that mean the code from felgall will look for 640px or less, does it even understand it? If so then that should be okay. Now I changed the code so there is no default, there shouldn’t have been anyway as the screen has to be one of the sizes and so there is always going to be a correct page.
I change the “window.location” to “popupCenter” as this made more sense, but nothing is loading now so I think its something just here that’s the issue as the dimensions are calculated and all the links work, its just that bit that the code does not understand, just the condition, not the calculations. What do you think?
@Mittineague: I take your point but I think that ridding all the functions is best for the window, its not a big deal really, only annoying I suppose but my webpage is size specific. No matter what you think, that’s the way it is.
@pmw57: Thanks but that’s not what I’m looking for.