开发者

jQuery doesn't work fully on a Firefox addon

开发者 https://www.devze.com 2023-01-07 23:11 出处:网络
I\'ve included jQuery by doing this: <?xml version=\"1.0\"?> <!DOCTYPE window SYSTEM \"chrome://orkutmanager/locale/browser.dtd\">

I've included jQuery by doing this:

<?xml version="1.0"?>
<!DOCTYPE window SYSTEM "chrome://orkutmanager/locale/browser.dtd">
    <overlay id="omcore" 
        开发者_Go百科 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">

    <script type="application/x-javascript" src="../../jquery-1.4.2.js"/>
    <script type="text/javascript">jQuery.noConflict();</script>

    <script type="application/x-javascript" src="../../OM.js"/>

</overlay>

Here is my chrome.manifest

content orkutmanager    chrome/content/
overlay chrome://browser/content/browser.xul chrome://orkutmanager/content/XUL/Browser/Core.xul

skin orkutmanager classic skin/

locale orkutmanager en-US locale/en-US/

And then I tried to use

gBrowser.addEventListener('DOMContentLoaded',
    function (e)
    {
        var contentWindow = e.originalTarget.defaultView;
        var contentDocument = contentWindow.document;

        var $ = jQuery;

        var x = $("a", contentDocument).attr("onclick"); //
        // Error: uncaught exception: unknown (can't convert to string)

    }, false);

While

$("a", contentDocument).get(0).getAttribute("onclick");

Works normal.

Do I have to include jQuery in a different way? How can I make it work as usual? Is there another jQuery method to get the value of an attribute?

On a normal case it works, example here.


You are accessing the onclick property using the attr function.

The docs say nothing about it, but could it be that attr() forces its return value into a string? It looks like it.

What if you access onclick directly? What are you doing with it?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号