javascript - Phaser 使用 Firefox(隐藏的 Iframe)崩溃到 null window.computedStyle()
问题描述
所有 Phaser 游戏引擎游戏似乎都会因以下错误而崩溃,但只有在iframe
包含实际 Phaser 游戏的内容因显示游戏前视频广告而被隐藏时才使用 Firefox。
类型错误“window.computedStyle() 为空”
任何解决方法?
解决方案
我认为您拼错了错误:它是“window.getComputedStyle()”。
尝试使用这段代码:
if (/firefox/i.test(navigator.userAgent)){
window.oldGetComputedStyle = window.getComputedStyle;
window.getComputedStyle = function (element, pseudoElt) {
var t = window.oldGetComputedStyle(element, pseudoElt);
if (t === null) {
return {
getPropertyValue: function(){}
};
} else{
return t;
}
};
}
推荐阅读
- time-series - STL分解后的大而一致的残基表示非周期性?
- angular - 更改月份时日期不正确
- c# - Word.ApplicationClass.Activedocument 突然出现异常
- python - 将示例代码从 Google SDK 运行到 RaspberryPi 3 时出错
- javascript - 如何使用变量引用 vuex 'constant' 命名操作?
- java - 在枚举的反序列化/序列化过程中寻找对这种奇怪行为的解释
- javascript - Firebase Auth Login 未显示登录用户名
- docker - Docker Desktop (Windows) 上的 Kubernetes 持久卷
- .htaccess - htaccess 到子目录而不更改地址栏 URL?
- python - 从文件中获取数据并将其插入列表