网页编程常用小技巧

网页编程常用小技巧

控制横向和纵向滚动条的显隐?
<body style="overflow-y:hidden"> 去掉x轴
<body style="overflow-x:hidden"> 去掉y轴
<body scroll="no">不显

--------------------------------------------------------------------------------
表格变色
<TD οnmοuseοver="this.style.backgroundColor='#FFFFFF'"
οnmοuseοut="this.style.backgroundColor=''"
style="CURSOR: hand">
--------------------------------------------------------------------------------
禁止复制,鼠标拖动选取
<body οndragstart=window.event.returnValue=false οncοntextmenu=window.event.returnValue=false onselectstart=event.returnValue=false>

--------------------------------------------------------------------------------
iframe自适应高度
<iframe name="pindex" src="index.asp" frameborder=false scrolling="auto" width="100%" height="100%" frameborder=no οnlοad="document.all['pindex'].style.height=pindex.document.body.scrollHeight" ></iframe>
--------------------------------------------------------------------------------
IE地址栏前换成自己的图标&可以在收藏夹中显示出你的图标
<link rel="Shortcut Icon" href="favicon.ico">
<link rel="Bookmark" href="favicon.ico">
--------------------------------------------------------------------------------
字号缩放
越来越多的人长时间的泡网,眼镜的普及率也越来越高,让文字大点,让更多的用户看的更清楚。
<script type="text/javascript">
function doZoom(size)
{document.getElementById('zoom').style.fontSize=size+'px';}
</script>
<span id="zoom">需要指定大小的文字</span>
<a href="javascript:doZoom(16)">大</a> <a href="javascript:doZoom(14)">中</a> <a href="javascript:doZoom(12)">小</a>
--------------------------------------------------------------------------------
select挡住div的解决方法
在div里加入下面的代码,根据需要调整就可以了。
<iframe src="javascript:false" scrolling="no" frameborder="0" style="z-index:-1;position:absolute; top:5px; left:2px;width:168;height:100px;">
</iframe>

--------------------------------------------------------------------------------
iframe(嵌入式帧)自适应高度
填写的嵌入地址一定要和本页面在同一个站点上,否则会提示“拒绝访问!”。对跨域引用有权限问题,请查阅其他资料。
<iframe name="guestbook" src="gbook/index.asp" scrolling=no width="100%" height="100%" frameborder=no οnlοad="document.all['guestbook'].style.height=guestbook.document.body.scrollHeight"></iframe>
--------------------------------------------------------------------------------
跳转菜单新窗口
<select name="select" οnchange="window.open(this.options[this.selectedIndex].value)">
<option value=""> Internet Explorer</option>
<option value=""> Microsoft Home</option>
<option value=""> Developer Network</option>
</select>
--------------------------------------------------------------------------------
flash透明选项
<param name="wmode" value="transparent">
--------------------------------------------------------------------------------
添加到收藏夹和设为首页
添加到收藏夹:
<a href="javascript:window.external.addFavorite('http://链接','说明');">添加到收藏夹</a>
设为首页:
<a href=# οnclick=this.style.behavior='url(#default#homepage)';this.setHomePage ('http://链接');>设为首页</a>
--------------------------------------------------------------------------------
记录并显示网页的最后修改时间
<script language=JavaScript>
document.write("最后更新时间: " + document.lastModified + "")
</script>
--------------------------------------------------------------------------------
节日倒计时
<Script Language="JavaScript">
   var timedate= new Date("October 1,2002");
   var times= "国庆节";
   var now = new Date();
   var date = timedate.getTime() - now.getTime();
   var time = Math.floor(date / (1000 * 60 * 60 * 24));
   if (time >= 0)
   document.write( "现在离"+times+"还有: "+time +"天")
</Script>
--------------------------------------------------------------------------------
加在HEAD里
禁止缓存
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">

--------------------------------------------------------------------------------
让IFRAME框架内的文档的背景透明
<iframe src="about:<body style='background:transparent'>" allowtransparency></iframe>
--------------------------------------------------------------------------------
打开窗口即最大化
<script language="JavaScript">
<!-- Begin
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
// End -->
</script>
--------------------------------------------------------------------------------
加入背景音乐
<bgsound src="mid/windblue[1].mid" loop="-1"> 只适用于IE
<embed src="music.mid" autostart="true" loop="true" hidden="true"> 对Netscape ,IE 都适用
--------------------------------------------------------------------------------
滚动
<marquee direction=up height=146 οnmοuseοut=start() οnmοuseοver=stop() scrollAmount=2>滚动信息
</marquee>
--------------------------------------------------------------------------------
防止点击空链接时,页面往往重置到页首端
代码“javascript:void(null)”代替原来的“#”标记 分类:网页编辑 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 37
打开任意网页(只要这个网页有图片)把地址栏地址改为下面的代码,你会有惊喜的作者:wuyilala 日期:2006-10-11
打开任意网页(只要这个网页有图片)
把地址栏地址改为下面的代码,你会有惊喜的
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position="absolute"; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval('A()',5); void(0);

查看更多...
分类:网页编辑 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 52
今天自己搞了个判断页面然后跳转的代码,觉得不错,保存下~现在404设置一个就行了~挺方便的作者:wuyilala 日期:2006-09-14
今天自己搞了个判断页面然后跳转的代码,觉得不错,保存下~现在404设置一个就行了~挺方便的
程序代码
<script Language="JavaScript">
<!--
       refreshurl = location.hostname;
       document.write(refreshurl);
       document.write("<meta http-equiv=refresh content='1;url=http://",refreshurl,"'>");
//-->
</script>
Location Properties
Properties Description         JS  IE  NS  OP  FF KQ  SF
hash 锚点,即#及其后面的锚点   1.0 3.0 2.0 7.1 1.0 3.3 1.2
host 主机名称+端口号       1.0 3.0 2.0 5.12 1.0 3.3 1.2
hostname 主机名称         1.0 3.0 2.0 5.12 1.0 3.3 1.2
href url完整地址          1.0 3.0 2.0 7.1 1.0 3.3 1.2
pathname 路径          1.0 3.0 2.0 7.1 1.0 3.3 1.2
port 端口             1.0 3.0 2.0 7.1 1.0 3.3 1.2
protocol 协议           1.0 3.0 2.0 7.1 1.0 3.3 1.2
search 搜索条件,即?及其后的参数字串 1.0 3.0 2.0 7.1 1.0 3.3 1.2    

Read more

Java设计模式——外观模式用法详解

Java设计模式——外观模式用法详解

外观模式(Facade Pattern)是Java开发中常用的设计模式之一,属于结构型设计模式,提供了一个统一的接口,用于访问子系统中的一群接口。外观模式定义了一个高层接口,使得子系统更容易使用,同时隐藏了子系统的复杂性,简化了客户端与子系统之间的交互,下面用Java代码来看看它的用法吧。 // 子系统A class SubsystemA { public void operationA() { System.out.println("子系统A"); } } // 子系统B class SubsystemB { public void operationB() { System.out.println("子系统B"); } } // 外观类 class Facade { private SubsystemA subsystemA; private SubsystemB subsystemB; public Facade() { this.subsystemA = new

By Ne0inhk
Java设计模式——组合模式用法详解。

Java设计模式——组合模式用法详解。

组合模式(Composite Pattern)是也是Java开发中常用的设计模式之一,属于结构型设计模式,用于将对象组合成树形结构以表示“部分-整体”的层次结构。组合模式使得用户可以以统一的方式处理单个对象和对象的组合,下面通过代码来看看它的使用。 import java.util.ArrayList; import java.util.List; // 组件接口 interface Component { void operation(); } // 叶子节点类 class Leaf implements Component { private String name; public Leaf(String name) { this.name = name; } @Override public void operation() { System.out.println("Leaf: " + name); } } // 容器节点类

By Ne0inhk
Java设计模式——适配器模式用法详解!!!

Java设计模式——适配器模式用法详解!!!

Java设计模式——适配器模式用法详解 * 适配器模式(Adapter Pattern)是Java开发中常用的设计模式之一,属于结构型设计模式,下面将从适配器模式的基本原理、代码示例、以及它的优点缺点和使用场景进行详细介绍。 一、基本原理 用于将一个类的接口转换成客户端期望的另一个接口。适配器模式允许原本由于接口不兼容而无法一起工作的类能够协同工作。 二、代码示例 // 目标接口 interface Target { void request(); } // 适配者类 class Adaptee { public void specificRequest() { System.out.println("Adaptee "); } } // 类适配器 class ClassAdapter extends Adaptee implements Target { @Override public void request() { specificRequest(); } } // 对象

By Ne0inhk
JavaScript的使用——常用对象API

JavaScript的使用——常用对象API

常见的JavaScript对象包括数组(Array)、字符串(String)、数字(Number)、对象(Object)、函数(Function)等。这些对象在JavaScript中有着广泛的应用,其中数组(Array)是使用最为频繁的对象之一,下面一一介绍。 1. 数组 // 创建一个数组 let fruits = ['apple', 'banana', 'cherry', 'date']; // 1. 遍历数组 fruits.forEach(fruit => { console.log(fruit); }); // 2. 添加元素到数组末尾 fruits.push('grape'); // 3.

By Ne0inhk