Basically, how do you do it? I'd asume it has something to do with: document.getElementsByTagName('a') and a for each, but I am not sure exactly how that would work. Basically I want to change all the hrefs of all the links on my page to the same thing. Thanks, Josh
I haven't had a chance to check this but it should work for(x in document.links) { document.links[x].href = 'yourlink.html'; } Code (markup): this would change all the link on that page to the same url. is that what you wanted to do
Aye, that is what I want it to do, but that code does not seem to work. I do have onlcick values for all my links too, so my current code is: function lockLinks(){ for(x in document.links) { document.links[x].href = 'http://google.com'; document.links[x].onclick = ''; } alert("Links locked") } Code (markup): Thanks
i've had a chance to have a look at the script and tested it in both IE and firefox and both seem to be working fine. put the following code ina new .html file and have a look for yourself <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <script> function locklinks() { for(x in document.links) { document.links[x].href = 'javascript:void(0)'; document.links[x].onclick = ''; } } function dummyLinkFuction() { } </script> <body> <a href="http://forums.digitalpoint.com/showthread.php?t=845622">link</a> <br /> <a href="http://forums.digitalpoint.com/showthread.php?t=845622">link</a> <br /> <a href="http://forums.digitalpoint.com/showthread.php?t=845622">link</a> <br /> <a href="http://forums.digitalpoint.com/showthread.php?t=845622">link</a> <br /> <a href="http://forums.digitalpoint.com/showthread.php?t=845622">link</a> <br /> <a href="http://forums.digitalpoint.com/showthread.php?t=845622">link</a> <br /> <a href="http://forums.digitalpoint.com/showthread.php?t=845622">link</a> <br /> <a href="http://forums.digitalpoint.com/showthread.php?t=845622">link</a> <br /> <input type="button" onclick="locklinks();" value="Stop Linking" /> </body> </html> Code (markup): Jon