Jump to content

HELP with setting targets for links


Krakko

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...