gpt4 book ai didi

javascript - 从 Greasemonkey 调用时 jQuery UI 对话框抛出错误

转载 作者:行者123 更新时间:2023-11-29 18:37:59 26 4
gpt4 key购买 nike

每当我尝试从Greasemonkey ......我相信这与限制有关XPCNativeWrapper https://developer.mozilla.org/en/XPCNativeWrapper#Limitations_of_XPCNativeWrapper,虽然我不是 100% 确定。

我使用的核心 jQuery 方法都没有导致错误(附加、css、提交、keydown、每个、...)。

这可能是 Greasemonkey 中的错误或由于Greasemonkey和jquery ui的交互,不过我真的有兴趣弄清楚如何让他们一起工作。

// ==UserScript==
// @name Dialog Test
// @namespace http://strd6.com
// @description jquery-ui-1.6rc6 Dialog Test
// @include *
//
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js
// @require http://strd6.com/stuff/jqui/jquery-ui-personalized-1.6rc6.min.js

// ==/UserScript==

$(document).ready(function() {
$('<div title="Test">SomeText</div>').dialog();
});

错误:[异常...“组件不可用”nsresult:“0x80040111(NS_ERROR_NOT_AVAILABLE)"location: "JS 框架::文件:///home/daniel/.mozilla/firefox/.../components/greasemonkey.js::匿名::第347行“数据:无][Break on this error] if (line) {

火狐版本:Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) Gecko/2009020911Ubuntu/8.04 (耐寒) Firefox/3.0.6

更新:标准 jQuery 库中的 focus() 方法也抛出同样的错误:

$('body').focus();

也许 UI 在某个时刻调用了 focus 方法?

任何帮助将不胜感激!

最佳答案

这个线程很老,但是使用 Greasemonkey 和 Jquery to focus() 的方法是向 jquery 对象添加一个 [0] 以将其转回 DOM 元素。

      //Example:  
$('#obj').focus(); //Does not work
document.getElementById('obj').focus(); //Works

//Hybrid:
$(#obj)[0].focus(); //Work around

关于javascript - 从 Greasemonkey 调用时 jQuery UI 对话框抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/564342/

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