popup.html重定向到新选项卡窗口中的login.html页面

popup.html to redirect to login.html page in new tab window

本文关键字:html 窗口 login 页面 选项 重定向 新选项 popup      更新时间:2023-09-26

我已经参考了许多帖子,甚至通过了提交

如何通过单击弹出窗口中的按钮将打开弹出窗口的窗口重定向到新页面?

谷歌Chrome扩展重定向不同页面

代码似乎对我不起作用。我正在谷歌扩展上显示一个弹出的winodw,它应该会将我重定向到新窗口/选项卡中的另一个页面。我正在Ubuntu机器上使用Chrome。

我的maninfest文件是:

      {
      "manifest_version": 2,
      "name": "One-click WebRTC",
      "description": "This extension is for 'browser action' with WebRTC.",
      "version": "1.0",
      "browser_action": {
        "default_icon": "icon.png",
        "default_popup": "popup4.html"
      },

}

我的popup4.html文件是:

`

<html>
  <head>
    <title> Web</title>
    <style>
      body {
        min-width: 700px;
        min-height: 700px;
        overflow-x: hidden;
      }
      img {
        margin: 5px;
        border: 2px solid black;
        vertical-align: middle;
        width: 75px;
        height: 75px;
      }
    </style>
<script type="text/javascript">
function loadlogin() {
     window.opener.location.href="http://localhost:8080/project/login.html";
}
</script>
  </head>
  <body>
  Google Chrome Extension : Load ......................

<a href="" onclick="loadlogin();">LOGIN </a></p>
  </body>
</html>

在清单中添加权限"选项卡"。

然后用这样的东西打开一个新的选项卡:

chrome.tabs.create({url: 'http://www.google.com'});

这里记录了它:http://developer.chrome.com/extensions/tabs.html