站内搜索: 您现在的位置: 肿瘤咨询在线 >> 文章中心 >> 网络检索 >> 正文

一些做网页时常用到的脚本或代码

更新时间:2003-6-8 12:47:24 来源:WEB 作者:web 可选字体【
1.使网页不能被“另存为”

<body>里面加下面这段:
<noscript>
<iframe src="*.htm">
</iframe>
</noscript>

2.彻底屏蔽鼠标右键

<body>里面加上下面这段:
<script language="javascript">
<!--
 
if (window.Event) 
  document.captureEvents(Event.MOUSEUP); 
 
function nocontextmenu() 
{
 event.cancelBubble = true
 event.returnvalue = false;
 
 return false;
}
 
function norightclick(e) 
{
 if (window.Event) 
 {
  if (e.which == 2 || e.which == 3)
   return false;
 }
 else
  if (event.button == 2 || event.button == 3)
  {
   event.cancelBubble = true
   event.returnvalue = false;
   return false;
  }
 
}
 
document.oncontextmenu = nocontextmenu;  // for IE5+
document.onmousedown = norightclick;  // for all others
//-->
</script>

2.超连接单元格变色

A:visited{TEXT-DECORATION: none}
A:active{TEXT-DECORATION: none}
A:hover{TEXT-DECORATION: underline overline}
A:link{text-decoration: none;}
表格单元,在单元格的<td>标记里加上:onMouseOut="this.style.backgroundColor='' "onMouseOver=this.style.backgroundColor='#E0E2ED'就可以了
onMouseOut="this.style.border='0px solid #cccccc';this.style.backgroundColor='' "onMouseOver="this.style.border='1px solid #cccccc';this.style.backgroundColor='#E0E2ED'"

3.细表格边框

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="158" height="68">
    <tr>
      <td width="158" height="68"> </td>
    </tr>
  </table>

4.网页全屏显示

把如下代码加入<body>区域中 
<SCRIPT LANGUAGE="javascript"> 
<!-- Begin 
if (this.name!='fullscreen'){ 
window.open(location.href,'fullscreen','fullscreen,scrollbars') 

// End --> 
</script> 
<a href="javascript:window.close(self)">返回正常效果显示</a>


5.表格虚线

使用CSS,新建一个Style,选择“Redefine HTML Tag”,在下拉菜单中选择“td”,在弹出对话框中的“Category”里选择“Border”,将Top、Left、Right、Bottom都设成1px,颜色设成你想要的边框的颜色。然后在“Style”下拉框里选择“Dashed”,点“OK”。这样所有的表格都变成虚线的了。
或:
<table><td style="border:dashed 1px #00000">test</td></table> 


6.连接全屏

<a href="#" onClick="window.open(URL,'','fullscreen=1')">Link</a> 
通过连接可以打开一个全屏窗口


7.DW层的定位

用菜单插入层,不要用面板的。 
主要就是不要设定层的left和right属性


8.css阴影滤镜

<div style="width:754;height:13;color:black;filter:dropshadow(color=white,offx=1,offy=1,positive=2);">  首页 关于本站 设计作品 </div>

<div style="width:75;height:1;color:black;filter:dropshadow(color=#cccccc,offx=1,offy=1,positive=2);" align="center"><font color="#414992"><a href="index.htm">首页</a></font></div>


9.关闭窗口

<a href="javascript:closewin();">关闭本页</a> 
  <script language=javascript>
function closewin() {window.close(); return;} 
</script>


0.图层的准确定位

在单元格里Insert/Layer,插入一个图层A(通过菜单插入的图层是相对定位),他的位置是跟着参照物改变的。接着图层A中插入一个图层B。这时你可移动图层B到任何位置。这时图层B的位置是绝对的,但这个绝对植的起点不是浏览器的左上角。而是图层A。


1.自动连接到另一页

<meta http-equiv="refresh" content="5;URL=index.htm">


2.虚线表格

<title>虚线</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.unnamed1 {  border: #000000; border-style: dotted; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px}
-->
</style>
</head>

<body bgcolor="#FFFFFF" text="#000000">

<table width="289" border="0" cellpadding="0" cellspacing="0" class="unnamed1">
  <tr>
    <td width="289" height="220"></td>
  </tr>
</table>
</body>


3.不同分辨率返回不同页面

<script language="javascript"> 
<!-- Begin 
if ((screen.width == 640) && (screen.height == 480)){ 
self.location.href='640*480.htm' 

else if ((screen.width == 800) && (screen.height == 600)){ 
self.location.href='800*600.htm' 

else if ((screen.width == 1024) && (screen.height == 768)){ 
self.location.href='1024*768.htm' 

else {self.location.href='else.htm' 

// End --> 
</script>


4.显示日期 

<script language="javascript"><!-- 
today=new Date(); 
var week; var date; 
if(today.getDay()==0) week="星期日" 
if(today.getDay()==1) week="星期一" 
if(today.getDay()==2) week="星期二" 
if(today.getDay()==3) week="星期三" 
if(today.getDay()==4) week="星期四" 
if(today.getDay()==5) week="星期五" 
if(today.getDay()==6) week="星期六" 
date=(today.getYear())+"年"+(today.getMonth()+1)+"月"+today.getDate()+"日"+" " 
document.write("<span style='font-size: 9pt;'>"+date+week+"</span>"); 
// --> 
</script> 

5.表格一行多个
在table里加style="float:left"

    免责声明:
    本文仅代表作者个人观点,与肿瘤咨询在线网站无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。


  • 上一篇文章:
  • 下一篇文章:
  • 网站简介 - 联系站长 - 友情链接 - 网站地图 - sitemap - 网站导航 - 进站必读 - 招纳义工