电脑爱好者,提供IT资讯信息及各类编程知识文章介绍,欢迎大家来本站学习电脑知识。 最近更新 | 联系我们 RSS订阅本站最新文章
电脑爱好者
站内搜索: 
当前位置:首页>> Asp>>asp编程开发常用的程序代码之三:

asp编程开发常用的程序代码之三

来源:www.cncfan.com | 2006-8-9 | (有2064人读过)

显示状态拦固定文字:
放在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="http://www.lingcom.net/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">



关闭窗口,这个是不会弹出提示直接关的:
把如下代码加入<body>区域中


<object id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="command" value="close">
</object>
<script language="javascript">function shutwin(){closes.click();return;}</script>
<a href="/lingcomnet/javascript:shutwin();">关闭本窗口</a>





有时候好不容易写出来的程序代码被别人抄去,心里一定不好受。这还是小事,但如果在我们的源代码中有一些不希望让别人知道的内容,比如密码、action的指向等,这些一旦被人利用,那后果有时是不堪设想的。而网页加密就是我们现在需要解决的问题。下面就我在网页制作中的一些经验向大家介绍一些简单的防范方法。
禁止右键
看到这里大家一定会想,这招有很多人介绍过了,而且破解的方法也有很多。但我这里要说的是另一种方法,而且我试了很多方法都没有能破解。具体如下:


<html>
<head>
<script>
function stop(){
alert("试试能破解吗?");
return false;
}
document.oncontextmenu=stop;
</script>
<boyd>你可以按右键、shift+f10和右ctrl左边的那个键试试!看能不能解。^_^</body>



大家试试,看能不能破解!你可以将alert("试试能破解吗?");这句去掉,这样当按右键时就什么反应也没有了,就好像没有右键功能一样。

禁示查看源代码
我们已经禁了右键,但从"查看"菜单下的"源文件"中同样可以看到源代码,下面我们就来解决这个问题:
其实这只要使用一个含有<frame></frame>标记的网页便可以达到目的。


<frameset>
<frame src="http://www.lingcom.net/你要保密的文件的url">
</frameset>


这样当有人使用"查看"下的"源文件"的时候,看到的将是上面的那段代码,而你真正的文件又躲过一劫。

禁示另存为
通过上面的两步好像你的源代码已经安全了,但别忘了,别人还可以将你的页面保存下来,再慢慢分析。不过别担心,下面我们来解决这个问题。
在你要保密的网页中加入以下代码:


<noscript><iframe src="http://www.lingcom.net/*.htm"></iframe></noscript>



彻底屏蔽右键方法。


<body oncontextmenu="return false">




双击页面后自动滚屏,单击后停止。


<script language=javascript>
var currentpos,timer;
function initialize()
{ timer=setinterval("scrollwindow()",16); }
function sc(){
clearinterval(timer);
}
function scrollwindow()
{currentpos=document.body.scrolltop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrolltop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>





设定脚本出错能继续运行


<script language="javascript">
function killerror()
{
return false;
}
window.onerror=killerror;
</script>


 

将彻底屏蔽鼠标右键

oncontextmenu="window.event.returnvalue=false"


可用于table

<table border oncontextmenu=return(false)><td>no</table>


取消选取、防止复制

<body onselectstart="return false">

不准粘贴


onpaste="return false"


防止复制


oncopy="return false;" oncut="return false;"
Asp热门文章排行
网站赞助商
购买此位置

 

关于我们 | 网站地图 | 文档一览 | 友情链接| 联系我们

Copyright © 2003-2024 电脑爱好者 版权所有 备案号:鲁ICP备09059398号