开发者

Want to pass URL with tab and URL information to PHP page

I want to take chrome extension tab information (title, url) and pass to a php page on m开发者_JAVA百科y server. I have it displaying the information but when I try to write an iframe with the information I can't get the information to the .php page.

Is there a better way to do this? Thanks!

{
  "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>


I figured out a solution.

<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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜