Safari Extension : retrieve full HTML code from a

2019-08-23 01:45发布

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条回答
一夜七次
2楼-- · 2019-08-23 02:26

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.

查看更多
登录 后发表回答