Safari Extension : retrieve full HTML code from a page

烈酒焚心 提交于 2020-01-07 02:57:26

问题


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.



来源:https://stackoverflow.com/questions/10322864/safari-extension-retrieve-full-html-code-from-a-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!