通过层来实现渐淡淡出
<script language="JavaScript1.2">
function makevisible(cur,which){
if (which==0)
cur.filters.alpha.opacity=100
else
cur.filters.alpha.opacity=50
}
</script>
<div style="width:200px;height:200px;filter:alpha(opacity=50);border:1px solid #000;background:#efefef" onMouseOver="makevisible(this,0)" onMouseOut="makevisible(this,1)">
ywicc.com
</div>
检查是否为首页
<HTML XMLNS:IE>
<HEAD>
<STYLE>
@media all {
IE/:HOMEPAGE {behavior:url(#default#homepage)}
}
</STYLE>
<SCRIPT>
function fnVerify(){
sQueryHome = oHomePage.isHomePage(oHomeHref.value);
alert(sQueryHome);
event.returnValue = false;
}
</SCRIPT>
</HEAD>
<BODY>
<IE:HOMEPAGE ID="oHomePage" />
<INPUT TYPE=text ID=oHomeHref VALUE="http://www.microsoft.com">
<INPUT TYPE=button VALUE="Verify" onclick="fnVerify()">
</BODY>
</HTML>
判断一个层是否被隐藏
判断一个层是否被隐藏?例如,如果某一个层是被隐藏的就弹出"你好"的新窗口
<div id="Layer1" style="position:absolute; width:200px; height:115px; z-index:1; display:none;">a</div>
<script language="JavaScript">
<!--
Layer1.style.display=="none"?alert("你好"):alert("hidden");
//-->
</script>
如何在javascript中使表单中的一个按钮无效
<form method=post action="" name="form1">
<input type="button" name="button1" value="51js.com">
</form>
<script language="JavaScript">
<!--
form1.button1.disabled=true;
//-->
</script>
刷新框架
我有一个框架网页,左右2个网页,现在我在主窗口(右页面)登陆后返回到主窗口页面,我如何让左边页面也能刷新呢?
<body onload="parent.leftFrame.location.reload();">
或者在页面的最后:
<script>
//leftFrame指左边框架的名字
parent.leftFrame.location.reload();
</script>
ID与name的区别
一个元素定义了id,引用该元素时直接用id属性,而name通常用在form中,且必须由document.form.***而来,也就是说,name属性定义的元素在脚本中是document对象的子对象。
我说不太清楚,反正这么个意思。
此外,ID标识在一个页面中原则上应该唯一,而name则不一定。
我要用文字做按扭提交表单,不用input,怎么做?
<form name="form1">
<a href="###" onclick="form1.submit()">提交</a>
</form>
图片reset表单
<form name=jie>
<input value="text">
<img src="http://be10.ods.org/51js/images/standard/report.gif"
onclick="document.jie.reset()"></form>
页面有多个CSS做个check box让用户选择
<HTML>
<HEAD>
<TITLE>换肤技术新的尝试</TITLE>
<link ID="skin" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE=javascript>
<!--
function SetCookie(name,value){
var argv=SetCookie.arguments;
var argc=SetCookie.arguments.length;
var expires=(2<argc)?argv[2]:null;
var path=(3<argc)?argv[3]:null;
var domain=(4<argc)?argv[4]:null;
var secure=(5<argc)?argv[5]:false;
document.cookie=name+"="+escape(value)+((expires==null)?"":("; expires="+expires.toGMTString()))+((path==null)?"":("; path="+path))+((domain==null)?"":("; domain="+domain))+((secure==true)?"; secure":"");
}
function GetCookie(Name) {
var search = Name + "=";
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset,end));
}
}
return returnvalue;
}
var thisskin;
thisskin=GetCookie("nowskin");
if(thisskin!="")
skin.href=thisskin;
else
skin.href="css.css";
function changecss(url){
if(url!=""){
skin.href=url;
var expdate=new Date();
expdate.setTime(expdate.getTime()+(24*60*60*1000*30));
//expdate=null;
//以下设置COOKIES时间为1年,自己随便设置该时间..
SetCookie("nowskin",url,expdate,"/",null,false);
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<P>请选择下面的下拉菜单测试换肤效果</P>
<select onchange="changecss(this.value)">
<option>选择样式单文件</option>
<script language="javascript">
var csss=new Array();
csss[0]="001.css";
csss[1]="002.css";
csss[2]="003.css";
csss[3]="004.css";
var i;
for(i=0;i<4;i++)
if(thisskin==csss[i])
document.write("<option value=/""+csss[i]+"/" selected>"+csss[i]+"样式单文件</option>");
else
document.write("<option value=/""+csss[i]+"/">"+csss[i]+"样式单文件</option>");
</script>
</select>
</BODY>
</HTML>
如何让iframe根据内容适应高度
请问如何让iframe根据内容适应高度
在第一次加载的时候就会自动根据内容适应高度
<iframe src="http://www.baidu.com" onload="this.height = this.document.body.offsetHeight;this.width=this.document.body.offsetWidth;"></iframe>
屏蔽右键
<a href="http://ywicc.com" onmousedown="if(event.button==2)alert('禁止')">ywicc.com</a>
网页屏保
<script language="JavaScript">
function screensave(){
test.value++;
if(test.value==5){
test.style.display='none';
document.all[4].bgColor='black';
}
}
function screenopen(){
test.value=0;
test.style.display='';
document.all[4].bgColor='';
}
</script>
<body onkeydown="screenopen()" onmousemove="screenopen()" onload="setInterval('screensave()',1000)">
5 秒屏保<input id="test">
定义打开网页时起始窗口的大小
<script for="window" event="onload">
window.resizeTo(500,300)
</script>
输入字母、数字的正则表达式
<input onkeyup="this.value = this.value.replace(/[^a-zA-Z/d]/g,'')" onbeforepaste="this.value = this.value.replace(/[^a-zA-Z/d]/g,'')">
不随页面滚动的层
<body onscroll="d1.style.top=document.body.scrollTop+10">
<div id="d1" style="position:absolute; top:10px; width:100px; height:100px; background-color:red;"></div>
<img width="1" height="1000">
一个表单里的同一个按钮提交两个页面
<script language="JavaScript">
function testform(){
window.open('','t1');
form1.action='1.htm';
form1.target='t1';
form1.submit();
window.open('','t2');
form1.action='2.htm';
form1.target='t2';
form1.submit();
window.open('','t3');
form1.action='3.htm';
form1.target='t3';
form1.submit();
}
</script>
<form name="form1">
<input name="test">
<input type="button" value="submit" onClick="testform()">
</form>
判断是不是数字
<INPUT TYPE="text" NAME="num"><INPUT TYPE="button" name="test" onclick="testNum()">
<SCRIPT LANGUAGE="JavaScript">
<!--
function testNum(){
var pattern=/^/d+$/g;
if (!(pattern.test(num.value)))
{alert("please input a number!")}
}
//-->
</SCRIPT>
alt和title的分行
<a href="#" title="换换换
行行行">test</a>
取消选取、防止复制
<body onselectstart="return false">
<p>111111111111111111111111111111111</p>
</body>
关闭输入法
<input style="ime-mode:disabled">