SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript code on href

    Hi,

    I want to run javascript code on href and it is not working.

    Any idea?

    Following is the example

    Code:
    <!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=iso-8859-1" />
    <title>href javascript</title>
    </head>
    <body>
    
    <div>
    <form name="frmTest" />
    
    <p>
    
    <a href="http://www.google.com?id=javascript:{document.getElementById('DragPanel').value;}" target="_blank">Click</a>
    </p>
    
    <p>
    
    <a href="http://www.google.com?id={document.getElementById('DragPanel').value;}" target="_blank">Click</a>
    </p>
    
    <p>
    
    <a href="http://www.google.com?id=document.getElementById('DragPanel').value;" target="_blank">Click</a>
    </p>
    
    
    <p>
    
    <a href="http://www.google.com?id=document.frmTest.DragPanel.value" target="_blank">Click</a>
    </p>
    
    
    
    <p>
    <input type="text" name="DragPanel" id="DragPanel" value="123" />
    </p>
    
    
    </div>
    
    </form>
    
    </body>
    </html>

    -Thanks
    Zohaib.

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2012
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    The problem is solved using W3School website.

    http://www.w3schools.com/jsref/prop_html_innerhtml.asp

    -Thanks
    Zohaib.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •