0
我创建一个Chrome扩展,用下面的代码在Chrome扩展中,如何通过browser_action(popup.html)获取网站的网址?
manifest.json的:
{
"name": "Project",
"version": "1.0.0",
"manifest_version": 2,
"description": "Popup when website requires Log in",
"browser_action":{
"default_icon":"icon_19.png",
"default_popup":"Popup.html"
}
}
Popup.html:
<html>
<head></head>
<body>
<div class="plus" id="plu"></div>
<script src="inline.js"></script>
</body>
</html>
inline.js:
window.onload = function() {
document.getElementById('plu').onclick=popup;
}
function popup() {
var link = document.URL;
alert("This is the Link : (" +link+ ")");
}
当我点击ID为'plu'的div时,它会得到popup.html的URL,但是n ot为网站。请帮助。谢谢 。
可能重复http://stackoverflow.com/questions/1979583/how-can-i-get -the-URL-FOR-A-谷歌铬选项卡) – CBroe