开发者

Safari Extension safari.application error

I'm making an extension for safari I created a context item with command = showNote

In debugger I get the follwing error TypeError: Result of expression 'safari.application' [undefined] is not an object on line 8(the last line)

are there any things you need to include or call before this works?

main.js

function showNote(event){
    if(event.command == "showNote"){
        addE开发者_运维知识库lement = document.createElement('<div id="safExtNote"><textarea id="safExtNoteText"></textarea><button id="safExtSave">Save</safExtNote></div>');
        document.body.appendChild(addElement)
        alert("im online");
    }
}
safari.application.addEventListener("command", showNote, false);


Just ran into this problem myself trying to create a toolbar command. Turns out I was putting the JS in the wrong place. I added it to the "Injected Extension Content" as a start script. Needed to create an HTML page that included the JS and set that as the Global Page File.

Switch that around and you should be set, assuming it's the same problem I just ran into.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜