#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    2
    Rep Power
    0

    problem with javascript:location.href


    I have a question for those who are familiar with JavaScript. I have a page say, Home.asp, with a button that redirects to another page EditMember.asp as follows:

    <input name="Submit" type="submit" value="Submit" onMousedown="javascript:location.href='EditMember.asp?EmailAddress=' + form1.EmailAddress.value">

    However, its behavior was inconsistent. For example, it works if I test it locally on my desktop or a LAN-connected Win2k machine. However when testing on a remote server through internet, it never works. On one remote server, clicking on the button only refreshes the Home.asp page itself without passing the QueryString. On another remote server belonging to a different ISP, clicking the button would pass the QuertString to the Home.asp again. Can anyone help on this problem?

    - Dhsieh
  2. #2
  3. :(){ :|:&};:
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Germany
    Posts
    297
    Rep Power
    11
    javascript:location.href='EditMember.asp?EmailAddress=' + form1.EmailAddress.value

    I don't know what the cause for the different problems are but I would try it first by addign "self." and removing the free spaces and changing the type to "button":


    <input name="btnSubmit" type="button" value="Submit" onMousedown="self.location.href='EditMember.asp?EmailAddress='+this.document.form1.EmailAddress.valu e" />


    and if that does not work you should try a function:

    <script>
    function RedirectUser() {
    self.location.href='EditMember.asp?EmailAddress='+this.document.form1.EmailAddress.value;
    }
    </script>
    <input name="btnSubmit" type="button" value="Submit" onMousedown="RedirectUser" />

    Good luck
    regards >_<

    ws. fgeller.de
    em. felix@fgeller.de
  4. #3

  5. Join Date
    Jun 2003
    Location
    Watford, UK
    Posts
    146
    Rep Power
    12
    change to:

    <input name="Submit" type="button" value="Submit" onClick="window.location.href='EditMember.asp?EmailAddress=' + form1.EmailAddress.value">

    should work now

    ----------------------------

    been beaten to it!
    Last edited by Lewis Matthews; August 20th, 2003 at 07:00 PM.
    Lewis Matthews

    http://www.madlou.com
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    2
    Rep Power
    0
    Hi fgeller,

    I changed the type to "button" and it now works. I can't believe that Dreamweaver MX did not set the type to "button" when I drag-and-drop from the toolbar! Thanks for your help.

    - Dhsieh

IMN logo majestic logo threadwatch logo seochat tools logo