我需要在任意html文件上加上一些簡單的密碼保護。它確實需要安全,但只是不加區分地使用roff-raff。我試着用下面的JS:密碼保護html頁面
var password;
var thePassword="secretpassword";
password=prompt('Enter Password',' ');
if (password==thePassword) { alert('Correct Password! Click OK to Enter!'); }
else { window.location="http://www.google.com/"; }
這在Firefox罰款,但似乎提示功能在IE中失敗,所以我們總是重定向到谷歌...
如何做任何建議簡單的密碼保護使用直的HTML頁面?
編輯:要清楚,它工作在Firefox罰款,並在IE中甚至沒有一個彈出對話框,要求在IE中「輸入密碼」
該代碼似乎在IE9上正常工作。我只是在這個jsfiddle中運行它,它的工作原理:http://jsfiddle.net/jfriend00/KkMRS/。你正在運行什麼版本的IE?我建議在提示中提示實際值。 – jfriend00