...

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



robcoles
08-13-2008, 04: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';
}
// -->
</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/

Philip M
08-13-2008, 08: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';
}
</script>



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

robcoles
08-15-2008, 01: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)

<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=lease&button=Submit

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


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

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


to:


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


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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum