Forum Moderators: open

Message Too Old, No Replies

Javascript Prompt Alternative

         

bobrobbob

10:24 am on Apr 14, 2010 (gmt 0)

10+ Year Member



Issue: I have a java script that bring up a simple password box, It works great in Chrome, Safari, firefox but I get a box in Internet explorer asking my customers to take another step to allow access. This is not good, Customers did not now what to do.

Error:
This website is using a scripted window to ask you for information. If you trust this website, click here to allow scripted windows

Microsoft response:
"Internet Explorer has blocked a website from using a small program (called a script) to display a separate window. Hackers sometimes use scripted windows to mimic legitimate windows, such as login screens, that appear on websites. If you trust the website and want to allow the scripted window, click the Information Bar, and then click Temporarily Allow Scripted Windows. To always allow scripted windows, check the Allow websites to prompt for information using scripted windows custom security setting."

Objective:
I now there is likely no way to by pass this, so i need a different solution. Possible a Form Box to be present on the site that when information is entered it passes the password to the javascript code to allow access?

Please help, this is actually urgent as I have already lost a customer :-(

CODE:
<script>
function getStyle()
{
var temp = document.getElementById("admintable").style.visibility;

return temp;
}

function switchMain()
{
var isAuthed = authenticate();
if(isAuthed){
var current = getStyle();

if( current == "visible" ){
document.getElementById("admintable").style.visibility = "hidden";
}else{
document.getElementById("admintable").style.visibility = "visible";
}
}

}
function authenticate()
{
if(readCookie('authenticated')!=null)
{
return true;
}
else{
var password=prompt("Enter Code","")
if (password =="1234")
{
createCookie('authenticated',true);
return true;
}
}
return false;
}

function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}


</script>


Here is what I found online:
[anyexample.com...]

Fotiman

1:43 pm on Apr 14, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld!

I would suggest you have a look at the Yahoo UI Library's [developer.yahoo.com] SimpleDialog widget [developer.yahoo.com]. It's very well documented and includes examples.

As a side note, I hope you're not relying on this for anything critical because you're storing the expected value of the "password" within the JavaScript, which means that anyone could simply look in the script to find the expected value.