[英]How to redirect url chrome-extension?
I'm using Google Developer Console and Oauth to develop a chrome extension so that user can login by google account.But I can not redirect to url like this 我正在使用Google Developer Console和Oauth开发chrome扩展程序,以便用户可以通过google帐户登录。但是我无法重定向到此类网址
chrome-extension://<id>
. chrome-extension://<id>
。
So how can this be solved ? 那么如何解决呢?
I know this is an older question, but I wondered too. 我知道这是一个比较老的问题,但我也想知道。 You have to use the built in chrome API for accessing your extension's HTML.
您必须使用内置的chrome API来访问扩展程序的HTML。
chrome.extension.getURL('options.html')
Send redirect url from a content script to a background page: 将重定向网址从内容脚本发送到后台页面:
chrome.extension.sendRequest({redirect: "http://redirect"});
In a background page update tab's url which would cause redirect: 在后台页面更新标签的网址中,这会导致重定向:
chrome.extension.onRequest.addListener(function(request, sender) {
chrome.tabs.update(sender.tab.id, {url: request.redirect});
});
Refer: How do I redirect to a URL using a Google Chrome Extension & Content Script? 参考: 如何使用Google Chrome扩展程序和内容脚本重定向到URL?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.