[转] Web开发中常用的JavaScript实现页面跳转
1、按钮式:
<INPUT name="pclog" type="button" value="GO" onClick="location.href='http://game.unimagic.cn'">
2、链接式:
<a href="javascript:history.go(-1)">返回上一步</a>
<a href="<%=Request.ServerVariables("HTTP_REFERER")%>">返回上一步</a>
3、直接跳转式:
<script>window.location.href='http://game.unimagic.cn';</script>
4、开新窗口:
<a href="javascript:" onClick="window.open(http://game.unimagic.cn','','height=500,width=611,scrollbars=yes,status =yes')">培训</a>
5、
<meta http-equiv="refresh" content="秒; url=下一个页面">
6、
<script language="JavaScript"> 
<!-- 
    var userAgent = navigator.userAgent; 
    var MSIEIndex = userAgent.indexOf("MSIE"); 
    if (userAgent.indexOf("Win") != -1 && userAgent.indexOf("MSIE") != -1 && userAgent.substring((MSIEIndex + 5),(MSIEIndex + 8)) >= 5.5) 
    window.location.replace("http://game.unimagic.cn"); 
//--> 
</script>
7、
<script language="javascript"> 
    location.replace("http://www.***.com") 
</script>
8、延时跳转 
<script language="javascript">
    setTimeout(window.location="http://game.unimagic.cn",1000);
</script>
9、
<script language="JavaScript" > 
    bName = navigator.appName; 
    if ((bName == "Netscape") || (bName == "Microsoft Internet Explorer")) 
        window.location=http://www.dinmo.net; 
</script>
10、
多域名指向同一空间代码:
<script>try { if( self.location == "http://玉米一/" ) { 
top.location.href = "http://玉米一/目录"; 
} 
else if( self.location == "http://玉米二/" ) { 
top.location.href = "http://玉米二/目录"; 
} 
else if( self.location == "http://玉米三/" ) { 
top.location.href = "http://玉米三/目录"; 
} 
else if( self.location == "http://玉米四/" ) { 
top.location.href = "http://玉米四/目录"; 
} 
else { document.write ("错误的访问地址") } } catch(e) { }</script>
11、显示进度条的跳转(一):
<form name="loading">
<p align="center">正在跳转,请稍后...</p>
<p align="center">
<input type="text" name="bar" style="border-style:none; background-color:#D3E8D0; font-weight:bold" />
<input type="text" name="percentage"style="border-style:none; background-color:#FFFFFF; max-width:30px"/>
</p>
<script language="javascript" type="text/javascript">  
var percent=0;          //百分比进度,显示在滚动条后面
var element="||";      //滚动条单元竖线
var elements="||";    //滚动条当前竖线
count();                //开始调用循环
function count(){  
     percent=percent+10;    //每次百分比加10
    elements =elements + element; //滚动条当前竖线增加一个滚动条单元竖线
    document.loading.bar.value=elements;  //设置窗体loading表单中bar元素的当前值
    document.loading.percentage.value=percent+"%";  //设置窗体loading表单中percentage元素的当前值
    if (percent<99){                    //percent小于99则继续循环
        setTimeout("count()",500);        //每500ms进行一次count()
    }  
    else{
         window.location = "http://game.unimagic.cn";    //percent达到100时跳转
    }  
}
</script>
12、显示进度条的跳转(二)
<p align=center><font color="red" size="2">正在进入,请等待,谢谢......</font></p>
<form name=loading> 
<input type=text name=chart size=46 style="font-family:Arial; font-weight:bolder; color:rgb(124,119,119); background-color:white; padding:0px; border-style:none;"> 
<br><input type=text name=percent size=46 style="color:rgb(138,134,134); text-align:center; border-width:medium; border-style:none;">
<script>
var bar = 0 
var line = "||" 
var amount ="||" 
count() 
function count(){ 
    bar= bar+2 
    amount =amount + line 
    document.loading.chart.value=amount 
    document.loading.percent.value=bar+"%" 
    if (bar<99){
        setTimeout("count()",10); 
    }else{ 
        window.location = "http://game.unimagic.cn"; 
    } 
}
</script>
                    
                
                
            
        
浙公网安备 33010602011771号