HTML - 只需点击一下即可打开2页

时间:2011-04-06 13:15:54

标签: html href

大家好日子。

我需要这样做:

我有一个文字。当我点击它时,我必须打开2页。这里没问题......但诀窍是我不允许使用js。那么......你能用html做到这一点吗?

6 个答案:

答案 0 :(得分:30)

如果没有JavaScript,则无法通过单击一个链接打开两个页面,除非两个页面都在单击链接打开的一个页面上。使用JS它是微不足道的:

<p><a href="#" onclick="window.open('http://google.com');
    window.open('http://yahoo.com');">Click to open Google and Yahoo</a></p>

请注意,这会被内置于网络浏览器中的弹出窗口拦截器阻止,但通常会通知您。

答案 1 :(得分:8)

<a href="http://www.omsaicreche.blogspot.com" onclick="location.href='http://www.omsaivatikanoida.blogspot.com';" target="_blank">Open Two Links With One Click</a>

我尝试了上面的代码。我无法在旧页面取得成功。我在博客中创建了一个新页面,并按照代码类型...我成功了

答案 2 :(得分:1)

不可能只使用html

答案 3 :(得分:1)

如果您有权编辑要打开的页面,您可以href到'A'页面,在A页面中,您可以在body标签的onpageload属性中链接到B页面。

答案 4 :(得分:-1)

你也可以打开两页以上试试这个

`<a href="http://www.microsoft.com" target="_blank" onclick="window.open('http://www.google.com'); window.open('http://www.yahoo.com');">Click Here</a>`

答案 5 :(得分:-6)

只使用html

才能完美运行
<head>
  <base href="https://polygit.org/polymer+1.11.3/webcomponents+webcomponents+:v0/components/">
  <script src="webcomponentsjs/webcomponents-lite.js"></script>
  <link rel="import" href="polymer/polymer.html">
  <link rel="import" href="iron-collapse/iron-collapse.html">
</head>
<body>
  <x-foo></x-foo>

  <dom-module id="x-foo">
    <style>
      .collapse-content {
        padding: 15px;
        border: 1px solid #dedede;
        background-color: lightgray;
      }
    </style>
    <template>
      <button on-click="toggle">Collapse</button>
      <iron-collapse id="collapse" opened horizontal>
        <div class="collapse-content">
          <div>Content goes here...</div>
        </div>
      </iron-collapse>
    </template>
    <script>
      HTMLImports.whenReady(function() {
        Polymer({
          is: 'x-foo',
          toggle: function() {
            this.$.collapse.toggle();
          }
        });
      });
    </script>
  </dom-module>
</body>