View Full Version : javascript Password script works IE6 not IE7?? Help

08-13-2008, 05:19 AM
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';
// -->

Here is html:

<p><FORM class="pad" >
<INPUT class="login" type="Button" onClick="check()" value="Quick Calculator Login">
Here is URL:

Philip M
08-13-2008, 09:38 AM
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:-

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';

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

08-15-2008, 02:53 AM
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)

<input type = "password" name = "passwd" id = "passwd" onblur = "locate()" />

<input name="button" type="submit" class="submit" id="button" value="Submit" />
IE7 goes straight to page on entering password
IE6 & firefox works on submitting
Safari goes to this:- http://www.translease.com.au/?passwd=lease&button=Submit

08-15-2008, 07:53 AM
Change this part of your markup:

<input type = "password" name = "passwd" id = "passwd" onblur = "locate()" />

<input type="submit" class="submit" value="Submit" />


<input type = "password" name = "passwd" id = "passwd"/>
<input type="button" class="submit" value="Submit" onclick="locate()"/>

And modify the script to:

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.