Chinaunix

标题: 一些JAVASCRIPT [打印本页]

作者: 周若水    时间: 2005-03-02 21:16
标题: 一些JAVASCRIPT
一些javascript
1.禁止右键

2.禁止选择
3.禁止粘贴
4.禁止直接访问 [必须框架内才行]
if (top == self)top.location.href = "page.htm";
5.禁止frame引用
if (top != self)top.location.href = "page.htm";
6.禁止功能键Shift,Alt,Ctrl
function key(){
if(event.shiftKey) alert("Shift不允许使用!");} document.onkeydown=key;
数据取得类
1.取得分辨率
document.write("宽为"+screen.Width+"高为"+screen.Height)
2.取得地址栏
document.write(self.location)
3.取得地址栏?后参数
var add = top.location;
add = add.toString();
document.write (add.substring(add.indexOf("?")+1,add.length));
常用特效类
1.主页遥控器
文件一.(t1.html)
window.open("t2.html","_blank","width=200","height=200","scroll=no");
文件二.(t2.html)
function op(add){if (window.opener){window.opener.document.location = add;}}
地址1
地址2
地址3
2.只弹一次的窗口
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {offset = document.cookie.indexOf(search)
    if (offset != -1) {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 jx165ad(){
if (get_cookie('jx165ad')==''){
document.cookie="jx165ad=yes"
window.open("ad.html","_blank","width=200","height=200","scroll=no");
}
else {}
}
jx165ad();
3.鼠标放在连接上强行点击
  
function mClk2() {var source=event.srcElement;if (source.tagName=="A"){source.click();self.focus();}}  
document.write("");  


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/4582/showart_13872.html




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2