lixw 发表于 2013-2-7 17:24:39

Web开发小技巧


[*]只显示垂直滚动条,不显示水平滚动条:设置body的style="overflow:scroll;overflow-x:hidden;overflow-y:yes;"
[*]禁用右键功能:设置body的oncontextmenu="return false;"
[*]禁用F5刷新:
window.document.onkeydown = disableRefresh;function disableRefresh(evt){ evt = (evt) ? evt : window.event if (evt.keyCode) {if(evt.keyCode == 116){   evt.keyCode = 0;   //window.document.location.reload();   return false;} }}    4.  Meta Refresh:
过5秒后刷新本页面:
<meta http-equiv="refresh" content="5"/>
过五秒后导向http://wikipedia.org页面:
<meta http-equiv="refresh" content="5;url=http://wikipedia.org"/>
立即导向http://wikipedia.org页面:
<meta http-equiv="refresh" content="0;url=http://wikipedia.org"/>
 
5. eval构造动态JS代码:
 
var tom = ['Tom', 'William'];function hello(name){   alert(["Hello, ", name, '!'].join(''));}var i = 0;var name = 't' + 'om[' + i + ']';hello(name); // Hello, tom!hello(eval(name)); // Hello, Tom! 
6. 打开一个小窗口:
function doIt(){window.open('new.html', 'NewWindow', 'height=100, width=400, top=300, left=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');window.opener=null;      window.open('','_self','');      window.close();}  
 
 
 
 
 
页: [1]
查看完整版本: Web开发小技巧