我正在开发Chrome扩展程序,以便轻松访问某些文档,基本上它是一个弹出窗口中的网站。
它工作正常,但当我关闭弹出窗口并再次打开它时,它会重新启动弹出窗口,我希望在关闭它之前保留用户所在的位置。
有什么想法吗?
------------截图--------------------
所以..我想要做的是当用户再次打开弹出窗口时,向他显示他正在观看的视图。
答案 0 :(得分:-1)
setPopup
是您需要识别的基本代码部分。
if(localStorage.Page && localStorage.Page != document.URL){
//STORE CURRENT PAGE
localStorage.Page = document.URL;
//TRIM STRING
var string = "chrome-extension://"+window.location.host+"/";
String.prototype.ltrim = function() {
return this.replace(string,"");
}
//SETPOPUP OVERWRITES MANIFEST DATA
chrome.browserAction.setPopup({
tabId: null, // Set the new popup for this tab.
popup: localStorage.Page.ltrim() // Open this html file within the popup.
});
}else{
localStorage.Page = document.URL;
}