我想获取chrome扩展标签信息(标题,网址)并传递到我服务器上的php页面。我有它显示信息,但当我尝试用信息编写iframe时,我无法将信息提供给.php页面。
有更好的方法吗?谢谢!
{
"name": "XXXXXX",
"version": "1.0",
"description": "Test.",
"browser_action": {
"default_icon": "icon.png",
"popup": "popup.html"
},
"permissions": [
"tabs",
"http://www.xxxxxxxx.com/*",
"bookmarks"
]
}
<html>
<head>
<style type="text/css">
body {width:100; height:50;}
</style>
<script language="Javascript">
chrome.tabs.getSelected(null,function(tab) {
var tablink = tab.url;
var tabtitle = tab.title;
alert(tablink);
alert(tabtitle);
document.write('<iframe src=http://www.xxxxxxxx.com/index.php?link=' + tablink + '&title=' + tabtitle + 'width=100 height=50 frameborder=0 scrolling=no');
});
</script>
</head>
<body>
</body>
</html>
答案 0 :(得分:0)
我想出了一个解决方案。
<html>
<head>
<style type="text/css">
body {width:100; height:50;}
</style>
<script language="Javascript">
chrome.tabs.getSelected(null,function(tab) {
var tablink = tab.url;
var tabtitle = tab.title;
if (tablink != "")
{
var url = "http://www.xxxxxxxx.com/index.php";
document.getElementById("phpcontent").innerHTML = "";
document.getElementById("phpcontent").innerHTML += "<iframe src='" + url + "?link=" + tablink + "&title=" + tabtitle + "' width='100' height='50' frameborder='0' scrolling='no'></iframe>";
}
else
{
exit();
}
});
</script>
</head>
<body>
<span id="phpcontent"></span>
</body>
</html>