我正在编写一个 Mozilla 扩展程序,通过使用此“window.content.mozInnerScreenY” API 来计算 Y 屏幕偏移。将 Firefox 升级到 33.1 版本后,我无法在最大化窗口中查看 Mozilla,尽管选择在最大化窗口中查看,但它会恢复到较小的窗口大小。只是为了仔细检查我在扩展的逻辑中评论了这行代码,然后窗口大小调整效果很好。
为什么上述值对我不起作用。请帮我解决这个问题。 代码如下:
**var appcontent = document.getElementById("appcontent");
var myExtension = {
init: function() {
// The event can be DOMContentLoaded, pageshow, pagehide, load or unload.
if(appcontent)
{
appcontent.addEventListener("resize", this.onmyPageResize, false);
}
},
onmyPageResize: function(aEvent) {
screenY= window.content.mozInnerScreenY;
//Process screenY
}
}
window.addEventListener("load", function load(event){
window.removeEventListener("load", load, false); //remove listener, no longer needed
myExtension.init();
},false);**
最佳答案
这个改变对我有用。 我对上面的代码做了一个非常小的更改:
const screenY = window.content.mozInnerScreenY。
我刚刚将 screenY 更改为 const 类型,因为 window.content.mozInnerScreenY 是一个只读值。
此更改解决了问题。
关于javascript - window.content.mozInnerScreenY 值在 Firefox 33.1 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27914809/