Simple JavaScript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • waqasmgl
    New Member
    • Nov 2007
    • 20

    Simple JavaScript

    Hi,
    I want to do this.

    Code:
    <a href="registration.aspx?returnUrl=<Current Page URL>">Registration</a>

    I want to place current pages' url in query string. I m doing this :
    Code:
    <a href="registration.aspx?returnUrl=javascript:current();&sessionTimeout=25&cancelUrl=javascript:current();">Registration</a>
    Current Function :
    Code:
    <script type="text/javascript">
    	Function current(){
    		document.write (document.location.href); 
    	}
    </script>
    Please guide me where i m wrong.

    Thanx in advance!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Please guide me where i m wrong.
    to be honest, pretty much everything.

    if this page is created through ASP or any other server side programming language, use that to print the URL. otherwise you have to construct the URL by JavaScript (but not inline JavaScript).

    Code:
    function attachURL()
    {
        this.href += "?returnUrl=" + encodeURIComponent(window.location.href); 
    }
    Code:
    <a id="register" href="registration.aspx">…</a>
    Code:
    var reg = document.getElementById("register");
    attachURL.call(reg);

    Comment

    Working...