HTML - 一键打开 2 页
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5566970/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTML - On one click open 2 pages
提问by zozo
Good day to all.
祝大家有个美好的一天。
I need to do this:
我需要这样做:
I have a text. When I click on it I must open 2 pages. No problem here... but the trick is that I am not allowed to use js. So... can you do this only with html?
我有一个文本。当我点击它时,我必须打开 2 页。这里没问题……但诀窍是我不允许使用 js。所以......你只能用html来做到这一点吗?
回答by Marcel
Without JavaScript, it's not possible to open two pages by clicking one link unless both pages are framed on the one page that opens from clicking the link. With JS it's trivial:
如果没有 JavaScript,就不可能通过单击一个链接打开两个页面,除非两个页面都在通过单击链接打开的一个页面上构建。使用 JS 是微不足道的:
<p><a href="#" onclick="window.open('http://google.com');
window.open('http://yahoo.com');">Click to open Google and Yahoo</a></p>
Do note that this will be blocked by popup blockers built into web browsers but you are usually notified of this.
请注意,这将被 Web 浏览器内置的弹出窗口阻止程序阻止,但您通常会收到通知。
回答by Dharmesh
<a href="http://www.omsaicreche.blogspot.com" onclick="location.href='http://www.omsaivatikanoida.blogspot.com';" target="_blank">Open Two Links With One Click</a>
I tried the above codes. I could not get success in old page. Than I created a new page in blogger and types following codes... I was successful
我试过上面的代码。我无法在旧页面中获得成功。然后我在博主中创建了一个新页面并输入以下代码......我成功了
回答by JohnSmith
it is not possible to do using only html
仅使用 html 是不可能的
回答by takirala
If you have the authority to edit the pages to be opened, you can href to 'A' page and in the A page you can put link to B page in onpageload attribute of body tag.
如果你有权限编辑要打开的页面,你可以href到'A'页面,在A页面中你可以在body标签的onpageload属性中放置到B页面的链接。
回答by betrice mpalanzi
also you can open more than two page try this
你也可以打开两个以上的页面试试这个
`<a href="http://www.microsoft.com" target="_blank" onclick="window.open('http://www.google.com'); window.open('http://www.yahoo.com');">Click Here</a>`
回答by vaibhav
it is working perfectly by only using html
仅使用 html 即可完美运行
<p><a href="#"onclick="window.open('http://google.com');window.open('http://yahoo.com');">Click to open Google and Yahoo</a></p>