I want to create elements which (when clicked) will guide visitors towards two differenct websites (both in new windows). How can I do this? Below are the two ways which I tried, which both do not work as only one page/ window is opened. Thanks in advance!
Timo
The solution as suggested here: How to make a link open multiple pages when clicked . But maybe the solution is outdated, but for me only the first webpage is openend (with all the indicated solutions. (for example the code which is suggested there)
HTML <a href="#" class="yourlink">Click Here</a>
$('a.yourlink').click(function(e) { e.preventDefault(); window.open('https://www.youtube.com/watch?v=H9XIXFwpyEc'); window.open('https://stackoverflow.com/search?q=open+multiple+pages'); });
While both using a class and an id with both a different a href and both with the extra options of opening new window also does not work as it only opens the first window
HTML <a href="#" class="yourlink" id="extra">Click Here</a>
$('.yourlink').html('<a href="url"></a>'); // Add page
$('.yourlink a').attr('target', '_blank');
// Make sure it opens in new window
$('#extra').html('<a href="url"></a>'); // Add page
$('#extra a').attr('target', '_blank');
// Make sure it opens in new window