Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2008
    Location
    Aus
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts

    javascript Password script works IE6 not IE7?? Help

    I have set up a javascript on http://www.translease.com.au
    To Access the Calculator page when you click button a dialogue box opens and a password is required (the password is the same name as the html file.)
    It works on IE6 and other browsers but not IE7?? WHY?
    The password box is not coming up but going direct to a (null) page.
    I am a novice so need help.
    thankyou Rob

    Here is the script:
    <SCRIPT language="JavaScript"><!--
    function check() {
    // Prompt user for the password ...
    pwd = prompt('Enter password before continuing','');

    location.href = 'http://www.translease.com.au/calculate/' + escape(pwd) + '.html';
    }
    // -->
    </SCRIPT>

    Here is html:

    <p><FORM class="pad" >
    <INPUT class="login" type="Button" onClick="check()" value="Quick Calculator Login">
    </FORM>
    </p>
    Here is URL:
    http://www.translease.com.au/

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,990
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    Your problem is that the JavaScript "prompt" function is blocked by IE7's default pop-up blocker.

    You need to change the code and script to:-

    Code:
    Enter the password:- <input type = "password" name = "passwd" id = "passwd" onblur = "locate()">
    
    <script type = "text/javascript">
    function locate() {
    var pwd = document.getElementById("passwd").value
    window.location.href = 'http://www.translease.com.au/calculate/' + escape(pwd) + '.html';
    }
    </script>


    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

  • Users who have thanked Philip M for this post:

    robcoles (08-15-2008)

  • #3
    New Coder
    Join Date
    Aug 2008
    Location
    Aus
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Dear Phillip
    Thankyou for your help. I replaced the script but didn't submit (go to page?)
    so added submit button which worked in some browsers not safari, netscape??
    Can you see where I am going wrong. (javascript as above)
    Code:
    <FORM>
                  <input type = "password" name = "passwd" id = "passwd" onblur = "locate()" />
                  
                  <input name="button" type="submit" class="submit" id="button" value="Submit" />
                        </FORM>
    IE7 goes straight to page on entering password
    IE6 & firefox works on submitting
    Safari goes to this:- http://www.translease.com.au/?passwd...&button=Submit
    Last edited by robcoles; 08-15-2008 at 04:03 AM. Reason: missed a bit of info

  • #4
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Change this part of your markup:
    Code:
     <FORM>
                  <input type = "password" name = "passwd" id = "passwd" onblur = "locate()" />
                  
                  <input type="submit" class="submit"  value="Submit" />
                        </FORM>
    to:
    Code:
    <p>
                  <input type = "password" name = "passwd" id = "passwd"/>
                  <input type="button" class="submit"  value="Submit" onclick="locate()"/>
                        </p>
    And modify the script to:
    Code:
    function locate() {
    var pwd = document.getElementById("passwd").value;
    (pwd!='')?window.location.href = 'http://www.translease.com.au/calculate/' + escape(pwd) + '.html':alert('Please provide the password.');}
    Hope that helps.
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph

  • Users who have thanked rangana for this post:

    robcoles (08-15-2008)


  •  

    Posting Permissions

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