【问题标题】:have an html link direct someone to another page and pop up another page有一个 html 链接将某人引导到另一个页面并弹出另一个页面
【发布时间】:2012-05-05 23:32:50
【问题描述】:

我曾尝试寻找这个问题的答案,但我的搜索空手而归。甚至很难弄清楚要搜索哪些术语。基本上我所拥有的是产品清单。我有您单击图片的功能,它会打开一个新选项卡,将您定向到外部链接,您可以在我的 a href 中使用 target =_blank 购买产品。我还希望图片指向另一个内部链接,您可以在其中评论和评价产品,只需在原始页面所在的同一选项卡中打开它(因此您基本上必须回击以返回主要产品清单。这可能吗?如果可以,怎么做? 提前感谢您的任何指导。

【问题讨论】:

    标签: html href


    【解决方案1】:
    <a href="url for new tab" target="_blank" 
      onclick="location.href = 'url for current tab'">Link</a>
    

    【讨论】:

    • 这对我来说可能效果更好,因为我希望 jscript 控制内部链接,html 控制新标签
    【解决方案2】:
    <script type="text/javascript">
       function openpages() {
    window.open("http://google.com");
    window.location = "http://yahoo.com"
       }
      </script>
    <a href=# onclick="openpages()">open product description</a>
    

    这将在新标签页中打开 Google,并在链接中打开 Yahoo

    【讨论】:

      【解决方案3】:

      如果我理解正确,您希望链接重定向到页面并打开弹出窗口?你试过Javascript的onclick吗?

      你可以这样做:

      <a href="thePage.html" onclick="window.open('thePopup.html')"><img src="myImage.png"/></a>
      

      【讨论】:

        【解决方案4】:

        很简单,使用onclick 处理程序和href 标签。

        <a href="#yourinternallink" onclick="window.open('popup.html')">
           <img src="link/to/my/image.jpg" />
        </a>
        

        【讨论】:

          猜你喜欢
          • 2013-12-13
          • 2019-11-19
          • 1970-01-01
          • 1970-01-01
          • 2011-08-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多