i'm trying to create a safari extension and i'm stuck with something.
I have my global.html on my extension and i've been searching the web for like 3hours on how to retrieve the full html code without success.
I tried:
document.getElementsByTagName('html')[0].innerHTML
(when i alert i only see the code that i have inside my global.html)
document.documentElement.innerHTML
(nothing happens)
etc...
I used safari.application.activeBrowserWindow.activeTab.url
to retrieve the url but i cant get the html code.
Any help?
Thank you
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You can't get the HTML of a web page from your extension's global page. You have to use an injected script and then, if you want, you can pass the web page's HTML to your global page using safari.self.tab.dispatchMessage
. See this chapter in Apple's documentation.