Get URL and page title data from SafariNavigateEvent

≡放荡痞女 提交于 2019-12-06 03:45:15

I would guess that the problem is that the title is actually defined within the page HTML. Since this is a beforeNavigate event, the page hasn't been loaded yet so in general the title isn't available yet, just the URL.

One solution might be to use the navigate event instead of beforeNavigate, provided you don't specifically need to do anything before the page actually loads. However I'm not sure that actually guarantees the page will be loaded, but it does make it more likely.

If it's still a problem, a more complicated alternative is to use an injected script that sends a message to the global page whenever a page loads. Use the DOM ready event in the injected script, then just dispatch a message to the global page containing the page title. Use if (window == window.top) to prevent embedded iframes from also sending a message.

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