web(ASP)常用代码[3]

[入库:2005年8月18日] [更新:2007年3月25日]

本文简介:选择自 lirefea 的 blog


显示状态拦固定文字:

放在body前
<base onmouseover="window.status='这里是goaler的blog系统,欢迎访问';return true">

用键盘打开网页

<script language=javascript>
document.onkeydown=gopage
var add="admin/addarticle.asp"
var logon="admin/logon.asp"
function gopage() {
 if (event.keycode==13) location=add
 if (event.keycode==38) location=logon
}
</script>

根据内容自动调整iframe高度

有时为了方便使用iframe,但被潜入的页面长度不是固定的,显示滚动条不仅影响美观还对用户操作带来不便,自动调整高度可以解决这个问题。^_^

function f_framestyleresize(targobj)
{
 var targwin = targobj.parent.document.all[targobj.name];
 if(targwin != null)
 {
  var heightvalue = targobj.document.body.scrollheight
  if(heightvalue < 600){heightvalue = 600} //不小于600
  targwin.style.pixelheight = heightvalue;
 }
}
function f_iframeresize()
{
 bloadcomplete = true;
 f_framestyleresize(self);
}

var bloadcomplete = false;
window.onload = f_iframeresize;


禁止页面正文内容被选取

<body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return 
false"onmouseup="document.selection.empty()"> 



消除ie6自动出现的图像工具栏,设置 galleryimg属性为false或no .

<img src="mypicture.jpg" height="100px" width="100px" galleryimg="no"> 



防止点击空链接时,页面往往重置到页首端。

代码“javascript:void(null)”代替原来的“#”标记 


如何避免别人把你的网页放在框架中 

<script language=“javascript”><!--if (self!=top){top.location=self.location;} -->< /script>



页面定时刷新

<meta http-equiv="refresh" content="秒" > 


页面定时转向新的地址

<meta http-equiv="refresh" content="秒;url=url"> 

本文关键:web(ASP)常用代码
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top