我有这段代码:
var masterHeight = $(window).height();
window.open("Agreement.aspx", "", "location=1,status=1,scrollbars=1, width=800,height=800");
如上所述,在window.open(..)中,宽度和高度被加密。但我想做一些事情:
window.open("...", "", "..., masterHeight-100");
我找不到将masterHeight(和masterWidth)变量作为参数的方法。这可能吗?
答案 0 :(得分:2)
只需将var附加到字符串,如下所示,
"location=1,status=1,scrollbars=1, width=800,height=" + masterHeight
完整代码:
window.open("Agreement.aspx",
"", // Added var masterHeight--v
"location=1,status=1,scrollbars=1, width=800,height=" + masterHeight);
答案 1 :(得分:1)
像这样用来执行数学运算:
var masterHeight = 800; window.open(“http://www.google.co.in”,“”,“location = 1,status = 1,scrollbars = 1,width = 800,height =”+(masterHeight-400));
检查这个JSFiddle_http://jsfiddle.net/7ULwX/5/>
不要忘记在浏览器中允许弹出窗口拦截器