通过jQuery Webworker访问窗口高度/宽度?

时间:2014-11-13 05:20:08

标签: jquery

有人可以建议是否可以从jQuery webworker进程中访问浏览器的高度/宽度?​​

这不会返回任何内容:

function getWindowDimensions() {
    output = "Screen width: " + $(window).width();
    output += "<br />";
    output += "Screen height: " + $(window).height();

    postMessage(output);
    setTimeout("timedCount()", 100);
}

getWindowDimensions();

提前致谢

1 个答案:

答案 0 :(得分:0)

检查JSfiddle: - JSFiddle

alert("Width: " + $(window).width());
alert("Height: " + $(window).height());