修改示例

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>
<div>
<a href="#" id="test_cors">跨域演示</a>
<a href="#" id="get_popup_title">获取popup页标题</a>
</div>
</div>
<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
function getCurrentTabId(callback)
{