修改示例

This commit is contained in:
liuxianan 2017-06-26 02:13:17 +08:00
parent c5ffb784a5
commit 0f518853f1
3 changed files with 15 additions and 5 deletions

View File

@ -18,6 +18,7 @@
<h1>这是背景页</h1> <h1>这是背景页</h1>
<div> <div>
<a href="#" id="test_cors">跨域演示</a> <a href="#" id="test_cors">跨域演示</a>
<a href="#" id="get_popup_title">获取popup页标题</a>
</div> </div>
</div> </div>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script> <script type="text/javascript" src="js/jquery-1.8.3.js"></script>

View File

@ -63,6 +63,15 @@ $('#test_cors').click((e) => {
}); });
}); });
$('#get_popup_title').click(e => {
var views = chrome.extension.getViews({type:'popup'});
if(views.length > 0) {
alert(views[0].document.title);
} else {
alert('popup未打开');
}
});
// 获取当前选项卡ID // 获取当前选项卡ID
function getCurrentTabId(callback) function getCurrentTabId(callback)
{ {

View File

@ -76,21 +76,21 @@
"chrome_url_overrides": "chrome_url_overrides":
{ {
// //
"newtab": "newtab.html" "newtab": "newtab.html"
}, },
// Chrome40 // Chrome40
"options_page": "options.html", "options_page": "options.html",
// Chrome402Chrome // Chrome402Chrome
"options_ui": "options_ui":
{ {
"page": "options.html", "page": "options.html",
// 使 // 使
"chrome_style": true "chrome_style": true
}, },
// //
"omnibox": { "keyword" : "go" }, "omnibox": { "keyword" : "go" },
// //
"default_locale": "zh_CN", "default_locale": "zh_CN",
// devtoolsHTMLJS // devtoolsHTMLJS
"devtools_page": "devtools.html" "devtools_page": "devtools.html"
} }