onClick="document.getElementById('child_<%=rs("id")%>').style.display=(document.getElementById('child_<%=rs("id")%>').style.display =='none')?'':'none'"
点击隐藏 点击显示的JS
替换函数
var name =document.getElementById("name");
name.value=name.value.replace(/'/,"‘");
String.prototype.replaceAll = function(s1,s2) {
return this.replace(new RegExp(s1,"gm"),s2);
}
数字验证
function checkNum(str){return str.match(/\D/)==null}
自己写的一个页面跳转(页面传参·页数)
<input type="text" id="jump_page" style=" width:40px" maxlength="10"/>
<input type="button" value="跳转" οnclick="jumppage();"/>
<script type="text/javascript">
function jumppage(){
var jump = document.getElementById("jump_page").value;
if(checkNum(jump)==false){return false;}
var url= document.URL;
if(url.match(/page=\d*/)==null){
if(url.match(/\?/)==null){url=url+"?page="+jump;}else{url=url+"&page="+jump;}}
else
{url=url.replace(/page=\d*/,"page="+jump);}
location.href=url;}
function checkNum(str){
if(str==""||str==undefined){return false;}return str.match(/\D/)==null}
String.prototype.replaceAll = function(s1,s2) {return this.replace(new RegExp(s1,"gm"),s2);}
</script>
history.go(-2)历史回退
//兼容火狐跟ie 的添加收藏夹动作
//使用例子:<a style="cursor:hand " οnclick="javascript:AddFavorite('http://www.xxxx.com/','标题')"> 加入我的收藏</a>
function AddFavorite(sURL, sTitle)
{
try
{
window.external.addFavorite(sURL, sTitle);
}
catch (e)
{
try
{
window.sidebar.addPanel(sTitle, sURL, "");
}
catch (e)
{
alert("加入收藏失败,请使用Ctrl+D进行添加");
}
}
}
//点击交换 显示的图片(已调试 ie 火狐 兼容)
例子:
大图:<tr><td width="473" height="600" align="center" id="main_pic" style="background-image: url(http://localhost:811/uploadimg/201203/20120317112012169_w473_h600.jpg);"><img width="473" height="600" src="/images/icon.gif"> </td></tr>
小图:<tr><td width="25%" height="190" align="center"><a οnclick="swapPic(1);"><img width="150" height="190" class="td_bg" id="randimg" name="randimg" src="http://localhost:811/uploadimg/201203/20120317112021851_w150_h190.jpg"></a></td><td width="25%" height="190" align="center"><a οnclick="swapPic(2);"><img width="150" height="190" class="td_bg" id="randpic" name="randpic" src="http://localhost:811/uploadimg/201203/20120317112027736_w150_h190.jpg"></a></td></tr>
//js代码
function swapPic(x){
var p = document.getElementById("main_pic");var a = document.getElementById("randimg");
var b = document.getElementById("randpic");
var reg=new RegExp("\"","g");
var temp;
if(x==1)
{
temp=p.style.backgroundImage.replace("url(","").replace(")","").replace("_w473_h600","_w150_h190");
temp=temp.replace(reg,"");
p.style.backgroundImage ="url("+a.src.replace("_w150_h190","_w473_h600")+")";
a.src = temp;
}
if(x==2)
{
temp=p.style.backgroundImage.replace("url(","").replace(")","").replace("_w473_h600","_w150_h190");
temp=temp.replace(reg,"");
p.style.backgroundImage ="url("+b.src.replace("_w150_h190","_w473_h600")+")";
b.src = temp;
}
}
String.prototype.replaceAll = function(s1,s2) {
return this.replace(new RegExp(s1,"g"),s2);
}
<script language="javascript">
//获取域名
host = window.location.host;
host2=document.domain;
//获取页面完整地址
url = window.location.href;
document.write("<br>host="+host)
document.write("<br>host2="+host2)
document.write("<br>url="+url)
</script>