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