1

Hey guys is there any way to add more than one link to the same thing?

What I want to do is to when some one clicks on a link they will be opening like two to three pages at the same time.

Lets say I have this:

<html>
    <head>
    </head>

    <body>
        <a>History</a>
    </body>
</html>

How I could make the link open more than one page?

J.Felipe
  • 60
  • 1
  • 2
  • 9
  • That sounds like a really spammy idea. why would you want to do this? People expect 1 link to open 1 destination. If you do more than that, it's likely not going to go over well with users. – scottohara May 14 '17 at 02:30

6 Answers6

2

You can do this by using JavaScript. See previous posts:

But since most browsers block popups like this, it's not a good idea to do something like this.

Zenima
  • 380
  • 2
  • 14
0

this might help,

    <a href="#" class="yourlink">Click Here</a>

In JS:

$('a.yourlink').click(function(e) {
e.preventDefault();
window.open('http://yoururl1.com');
window.open('http://yoururl2.com');
});

Window.open is sometimes blocked by popup blockers and/or ad-filters. To learn more, visit http://www.javascript-coder.com/window-popup/javascript-window-open.phtml

Sdp
  • 192
  • 3
  • 25
0

No that cannot be done strictly with HTML. However, you can use javascript or jquery to do this. Here is an example.

Your HTML a tag needs to fire a javascript function:

<a onclick="runredirect()">Click me!</a>

Then add a script tag at the end of your body:

<script type="text/javascript">
    var runredirect = function() {
        var redirectWindow1 = window.open('http://google.com', '_blank');
        redirectWindow1.location;
        var redirectWindow2 = window.open('http://yahoo.com', '_blank');
        redirectWindow2.location;
        var redirectWindow3 = window.open('http://bing.com', '_blank');
        redirectWindow3.location;
    }
</script>

That should do the trick.

Hurricane Development
  • 2,449
  • 1
  • 19
  • 40
0
<a href=”#link1″ onclick=”window.open(‘#link2′); window.open(‘#link3′)”>Page link </a>

By using above code you can add any number of pages, as I added three.

0

You can't with HTML alone, there's only a single href attribute.

You can do it with Javascript. Something along these lines:

<script>
function openLinks(links) {
  for (let link of links) window.open(link, '_blank');
}
</script>
<a onclick="openLinks(['https://www.google.com/', 'https://www.amazon.com'])">History</a>
Kenji
  • 726
  • 5
  • 9
0

Use the window.open() method in Javascript:

document.getElementById('clickme').addEventListener('click', function(){
     window.open('https://www.google.com', '_blank');
     window.open('https://www.bing.com', '_blank');

})

You can read more here.

jeremye
  • 1,368
  • 9
  • 19