Why does an absolute value (ie left=400) work in the window.open method but passing a variable doesnt? (see code below):
function openwindow(){
var w = window.innerWidth;
var h = window.innerHeight;
var wc= (w - 200);
var hc= (h - 200);
var strWindowFeatures = " toolbar=no,location=no,directories=no,status=no,menubar=no,titlebar=no,scrollbars=no,resizable=no,width=400,height=400,left=wc";
window.open("pop-up.html","mywindow", strWindowFeatures);
}
Also what doesnt seem to work is: a. toolbar (url bar) still shows up b. based on this url: https://developer.mozilla.org/en-US/docs/Web/API/Window/open
the centerscreen feature should work... (although does not state browser support).
You are passing "wc"
, not the value of wc
. Change this:
"....,left=wc";
to
"....,left=" + wc;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.