Need Help with URL Modification - Will PayPal $$$

Discussion in 'JavaScript' started by JackIT, Nov 27, 2008.

  1. #1
    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.
     
    JackIT, Nov 27, 2008 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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:
     
    MMJ, Nov 27, 2008 IP
  3. JackIT

    JackIT Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3


    tried it in FF and IE with no success
     
    JackIT, Nov 27, 2008 IP
  4. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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:
     
    MMJ, Nov 27, 2008 IP
  5. vic_msn

    vic_msn Well-Known Member

    Messages:
    2,233
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    155
    #5
    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
     
    vic_msn, Nov 28, 2008 IP
  6. cipals15

    cipals15 Well-Known Member

    Messages:
    1,085
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    100
    #6
    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.
     
    cipals15, Nov 28, 2008 IP
  7. JackIT

    JackIT Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7


    please PM me your PayPal ID.

    this worked exactly like I needed.

    thank you.
     
    JackIT, Nov 28, 2008 IP
  8. JackIT

    JackIT Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    sorry, no html changes
     
    JackIT, Nov 28, 2008 IP
  9. JackIT

    JackIT Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9


    Payment Sent!

    Thanks!
     
    JackIT, Nov 30, 2008 IP