gpt4 book ai didi

javascript - Firefox 扩展弹出窗口不会调整大小

转载 作者:可可西里 更新时间:2023-11-01 13:03:30 26 4
gpt4 key购买 nike

我正在努力将一个扩展程序从 Chrome 移植到 Firefox。弹出窗口有几个可以显示的不同大小的元素。我遇到的问题是当元素更改或 body 调整大小时显示弹出窗口的“窗口”不会调整大小。

这个问题在 chrome 中似乎不存在,有谁知道我做错了什么或者这是 Firefox 中的错误?我在下面包含了更改正文大小的代码,这在 chrome 中有效,但在 Firefox 中似乎无效。

$('body').ready(function(){
$('body').animate({
'width':500,
'height':500
},500);
});

我也尝试过使用 $('body').css() 以防 animate() 出现问题,但都不起作用。

此外,如果我将背景添加到 body 并缩小它,那么可以看到背景的大小发生了变化,而包含窗口的大小没有发生变化。

编辑:添加更多信息以澄清问题

该扩展是一个 WebExtension 附加组件 ( https://developer.mozilla.org/en-US/Add-ons/WebExtensions )

list .json

{
"manifest_version": 2,
"browser_action": {
"default_popup": "popup.htm"
},
"description": "Example extension",
"icons": {
"128": "example.png"
},
"name": "Example Extension",
"version": "1",
"applications":{
"gecko":{
"id":"example@example.com"
}
}
}

弹出窗口.htm

<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type=text/javascript src="js/jquery.js"></script>
<script type=text/javascript src="js/popup.js"></script>
</head>
<style>
body{
width:200px;
height:200px;

border:1px solid black;
}
</style>
<body>
<button id=reset type=button>200x200px</button>
<button id=shrink type=button>100x100px</button>
</body>
</html>

js/popup.js

$('body').ready(function (){
$('#reset').bind('click',function(){
$('body').css({
width:200,
height:200
});
});
$('#shrink').bind('click',function(){
$('body').css({
width:100,
height:100
});
});
});

加载上述扩展程序后,弹出窗口会正确显示其初始大小 (200x200)。但是,当调整正文大小时,弹出窗口的大小不会更新。这个相同的扩展在 Chrome 中按预期工作(弹出窗口调整大小)。

最佳答案

看来这实际上是 Firefox 中的错误,正在解决

https://bugzilla.mozilla.org/show_bug.cgi?id=1215025

关于javascript - Firefox 扩展弹出窗口不会调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36063269/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com