1. 禁用backspacke
document.onkeydown = function()
{
if (event.keyCode == 8 )
{
event.cancelBubble = true
event.returnValue = false;
return false;
}
}
2. 禁止状态栏显示连接
function window.onload()
{
var olink = document.links;
for(var i = 0; i < olink.length; i++)
{
olink[i].onmouseover = function() {
window.status='';
return true;
}
//解决.按住鼠标不松开还是会显示链接地址
olink[i].onfocus = function() {
window.status='';
return true;
}
}
}
3. 让页面的文本框显示成一条直线。
<input type=text style="border-left:none; border-right:none; border-top:none; border-bottom: 1 solid #000000"></input>
4. 不要滚动条
让竖条没有:
<body style="overflow:scroll;overflow-y:hidden"></body>
让横条没有:
<body style="overflow:scroll;overflow-x:hidden"></body>
两个都去掉:
<body scroll="no"></body>
5. 怎样去掉图片链接点击后,图片周围的虚线?
<a href="#" onFocus="this.blur()"><img src="/logo.jpg" border=0></a>
6. 脚本永不出错
window.onerror = function() {
return true;
}
7. 关闭输入法
<input style="ime-mode:disabled">
8. 在规定时间内跳转
<META http-equiv=V="REFRESH" content="5;URL=http://zhuxinyu.javaeye.com">
9. 发送邮件
<a href="mailto:xinyu_zhu@126.com">给我邮件</a>
10. 页面文字移动
<marquee direction="left" οnmοuseοut="start();" οnmοuseοver="stop();" scrollamount=2>我在移动</marquee>
11. 显示系统但前日期
function getCurrentDate()
{
var isnMonth = ["1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"];
var isnDay = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");
var today = new Date () ;
var Year=today.getYear();
var date=today.getDate();
if (document.all)
{
document.title="今天是: "+ Year + "年" + isnMonth[today.getMonth()] + date + "日" + isnDay[today.getDay()]
}
}
12. 各种样式的光标 style="cursor: hand"
auto :标准光标
default :标准箭头
hand :手形光标
wait :等待光标
text :I形光标
vertical-text :水平I形光标
no-drop :不可拖动光标
not-allowed:无效光标
help :?帮助光标
all-scroll :三角方向标
move :移动标
crosshair :十字标
13. 禁止右键菜单
oncontextmenu = "self.event.returnValue=false"
14. 控制页面编码
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
15. 不准黏贴
οnpaste="return false" 不准粘贴
16. 取消选取、防止复制
<body onselectstart="return false">
17. 在js 中写中文,防止乱码
<script type="text/javascript" src="code.js " charset="GBK"></script>
18. 复制粘贴板
function copyContentToPlate()
{
clipboardData.setData("text", "这些是粘贴内容");
}
19. 整体页面跳转
不存在frame框架的时候 window.location.href = "";
存在frame框架的时候 window.top.location.href = "";
20. 判断数据是否是IP
function isIP(ipInfo)
{
var ipReg = /^([1-9]|[1-9]/d|1/d{2}|2[0-1]/d|22[0-3])(/.(/d|[1-9]/d|1/d{2}|2[0-4]/d|25[0-5])){3}$/;
return ipReg.test(ipInfo);
}
21. 返回上一个页面
javascript:history.go(-1);
22. 在打开的子窗口刷新父窗口
window.opener.location.reload();
23. 获得地址栏中的地址
window.location.href;
24. 在HTML页面中获得URL重写中的参数。
function getParameter(paraStr, url)
{
var result = "";
var str = "&" + url.split("?")[1];
var paraName = paraStr + "=";
if (str.indexOf("&" + paraName) != -1)
{
if (str.substring(str.indexOf(paraName),
str.length).indexOf("&") != -1)
{
var TmpStr = str.substring(str.indexOf(paraName), str.length);
result = TmpStr.substr(
TmpStr.indexOf(paraName),
TmpStr.indexOf("&") - TmpStr.indexOf(paraName));
}
else
{
result = str.substring(str.indexOf(paraName), str.length);
}
}
else
{
result = "没有该参数";
}
return (result.replace("&", ""));
}
调用方法:
http://localhost/vod/man/streamingMedia.html?movieID=17735&movieUrl=2
var movieUrl = getParameter('movieUrl', window.location.href).split("=")[1];
alert("movieUrl: " + movieUrl);
结果: 17735
js
最新推荐文章于 2025-05-14 14:41:23 发布