ibtreyt Posted May 7, 2015 Share Posted May 7, 2015 Hey guys, was wondering if there is a way to create 1 <a> tag that has multiple targets, e.g. <a href="www.site1.co.uk" href2="www.site2.co.uk" href="www.site3.co.uk" target="_BLANK"> So it has 3 different locations that all open in their own tab. I made a PHP function that looks like this: <?php function GetLinks { $statement->prepare("SELECT * FROM Links"); $statement->execute } $Links = GetLinks(); foreach ($Links as $Link) { echo '<a href="'.$Link.'" target="_BLANK" />' } ?> I couldn't make it work though... is there a way I can impliment my objective with PHP? Quote Link to comment https://forums.phpfreaks.com/topic/296129-create-a-hyperlink-that-has-multiple-targets/ Share on other sites More sharing options...
Muddy_Funster Posted May 7, 2015 Share Posted May 7, 2015 nope you'll need javascript Quote Link to comment https://forums.phpfreaks.com/topic/296129-create-a-hyperlink-that-has-multiple-targets/#findComment-1511024 Share on other sites More sharing options...
ibtreyt Posted May 7, 2015 Author Share Posted May 7, 2015 So how would I use Javascript to do it? Quote Link to comment https://forums.phpfreaks.com/topic/296129-create-a-hyperlink-that-has-multiple-targets/#findComment-1511025 Share on other sites More sharing options...
ginerjm Posted May 7, 2015 Share Posted May 7, 2015 Your code is the worst thing I've ever seen posted here. Of course it won't work! That said - just what are you trying to do here? Why would you want to send your users to THREE sites at the same time? Whatever is the point of that? And just how are you going to present these sites to the client? Three separate tabbed windows in your browser? Great! I'm happily browsing along and you have this link that I click on and suddenly my browser explodes with stuff! Or as was suggested, you use a JS function (I hope you can write js functions better than you attempted to write a php one!) that will pop up 3 new windows (users just LOVE when that happens!) over the existing window. Is that what you are picturing? Yes - this is harsh, but really - think about what you are proposing. Quote Link to comment https://forums.phpfreaks.com/topic/296129-create-a-hyperlink-that-has-multiple-targets/#findComment-1511029 Share on other sites More sharing options...
ibtreyt Posted May 7, 2015 Author Share Posted May 7, 2015 (edited) Tis rather simple really, if you have multiple events that share the same name - e.g. a quarterly seminar about.. PHP (for instance) and I want to show a client all of them in 1 link instead of me seeming to bombarding them with link after link. and Aye, 3 seperate tabs in 1 window and its not for a website, its for HTML emails. I explained what I wanted, its you who need to think how you talk to beginners instead of discouraging users entirely. Thanks for the help. Edited May 7, 2015 by ibtreyt Quote Link to comment https://forums.phpfreaks.com/topic/296129-create-a-hyperlink-that-has-multiple-targets/#findComment-1511030 Share on other sites More sharing options...
Solution Zane Posted May 7, 2015 Solution Share Posted May 7, 2015 Give the anchor tag an id <a id='threelinks' href='#'>Open three tabs</a> then use jQuery (or Javascript ) $("a#threelinks").on('click', function() { window.open('page1.php', 'first page'); window.open('page2.php', 'secondpage'); window.open('page3.php', 'third page'); return false; }); Quote Link to comment https://forums.phpfreaks.com/topic/296129-create-a-hyperlink-that-has-multiple-targets/#findComment-1511031 Share on other sites More sharing options...
ibtreyt Posted May 7, 2015 Author Share Posted May 7, 2015 Thank you ^.^ Give the anchor tag an id <a id='threelinks' href='#'>Open three tabs</a> then use jQuery (or Javascript ) $("a#threelinks").on('click', function() { window.open('page1.php', 'first page'); window.open('page2.php', 'secondpage'); window.open('page3.php', 'third page'); return false; }); Quote Link to comment https://forums.phpfreaks.com/topic/296129-create-a-hyperlink-that-has-multiple-targets/#findComment-1511032 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.