Krakko Posted October 6, 2006 Share Posted October 6, 2006 So I was wondering if there was any way to set all links on a page to a certain target, like target="_blank" or target="_top" but without having to go through every single link and add that on. because i have a page with a lot of normal links with no targets, and it would take a really really long time to change them all individuallythanks Link to comment Share on other sites More sharing options...
jesh Posted October 6, 2006 Share Posted October 6, 2006 You could have some javascript do it for you:java script: function addTargets(){ var anchors = document.getElementsByTagName("a"); var count = anchors.length; for(var i = 0; i < count; i++) { anchors[i].target = "_blank"; }}window.onload = addTargets; Save that to a js file and include it in your code: <script type="text/javascript" src="myfile.js"></script> Link to comment Share on other sites More sharing options...
scott100 Posted October 6, 2006 Share Posted October 6, 2006 You can do this with plain html - <base target="_blank" />Example: http://www.w3schools.com/tags/tryit.asp?fi...me=tryhtml_base Link to comment Share on other sites More sharing options...
Krakko Posted October 6, 2006 Author Share Posted October 6, 2006 cool I was looking through those examples but couldn't find anything before, anyways thanks Link to comment Share on other sites More sharing options...
jesh Posted October 6, 2006 Share Posted October 6, 2006 You can do this with plain html - <base target="_blank" />I can't believe I forgot about that. heh. Link to comment Share on other sites More sharing options...
holmedwa04 Posted October 7, 2006 Share Posted October 7, 2006 If you are using Notepad 2 as your editor, you could do a find and replace on a certain bit of your code? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now