一些常用的js代码(2)

7.跳出小窗口
<script language="JavaScript"> 
window.open(
"window.html","redriver","toolbar=no, status=no,menubar=no, scrollbars=no,resizable=no,width=468,height=60"); 
</script>
8.刷新本页
<href="java script:location.reload()" target="_self">刷新</a>
9.跳出窗口
<script language="JavaScript"> 
window.open(
"window.html","redriver","toolbar=no, status=no,menubar=no, scrollbars=no,resizable=no,width=468,height=60"); 
</script>
10.屏蔽右键并自动导航
<script language="JavaScript"> 

if (navigator.appName.indexOf("Internet Explorer"!= -1
document.onmousedown 
= noSourceExplorer; 

function noSourceExplorer() 

if (event.button == 2 │ event.button == 3

alert(
"禁止右键..."); 


</script> 
11.进入页面之前要求输入密码
<script language="JavaScript"> 
function password() { 
var testV = 1
var pass1 = prompt('请输入密码(密码是welcome):',''); 
while (testV < 3) { 
if (!pass1) 
history.go(
-1); 
if (pass1 == "welcome") { 
alert('密码正确
!'); 
break

testV
+=-1
var pass1 = 
prompt('密码错误
!请重新输入:'); 

if (pass1!="password" & testV ==3
history.go(
-1); 
return " "

document.write(password()); 
</script> 
12.仅弹出一次窗口
<body onunload="loadpopup()"> 
<SCRIPT language="JavaScript"> 
<!-- 
function openpopup(){ 
window.open(
"welcome.htm","","width=300,height=300"


function get_cookie(Name) { 
var search = Name + "=" 
var returnvalue = ""
if (document.cookie.length > 0) { 
offset 
= document.cookie.indexOf(search) 
if (offset != -1) { // if cookie exists 
offset += search.length 
end 
= document.cookie.indexOf(";", offset); 
if (end == -1
end 
= document.cookie.length; 
returnvalue
=unescape(document.cookie.substring(offset, end)) 


return returnvalue; 


function loadpopup(){ 
if (get_cookie('popped')==''){ 
openpopup() 
document.cookie
="popped=yes" 



//--> 
</SCRIPT> 
posted on 2006-03-02 13:11  Ameng  阅读(202)  评论(0)    收藏  举报