Given the following: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test</title> </head> <body> This is a test blah blah blah. <a href="http://www.google.com" target="_blank">Click Here</a><br /> More blah blah blah. <script language="JavaScript" type="text/javascript" src="include.js"></script> </body> </html> HTML: I need the code that would be required in include.js so that when a person clicks on "Click Here" instead of going to http://www.google.com, they are sent to http://www.msn.com There cannot cannot be any changes to the HTML posted above. first person to supply me with a working script will recieve $20 through PayPal. Thanks.
var a = document.getElementsByTagName("a"), i = 0; for (; a[i]; i++){ if (a[i].href == "http://www.google.com") a[i].href = "http://www.msn.com"; } PHP:
Heh, simple slash problem. Fixed: var a = document.getElementsByTagName("a"), i = 0; for (; a[i]; i++){ if (a[i].href == "http://www.google.com/") a[i].href = "http://www.msn.com"; } PHP:
this is what I tried and it works <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test</title> <script language="JavaScript" type="text/javascript"> function linkcloak(){ location.href="http://www.msn.com"; } </script> </head> <body> This is a test blah blah blah. <a href="http://www.google.com" target="_blank" onclick="linkcloak(); return false;">Click Here</a><br /> More blah blah blah. </body> </html> HTML: Just put that content inside the script tags in your javascript file. But I have added the onclick event
Grrr.. I should have read this awhile ago. I should have supplied the code that vic_msn made. We had similar ideas. Anyway, i the first one received the $20 in their paypal. I am currently searching for money sources so that i could transfer my blogspot blog to a web host.