當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
JS跳转功能的汇总
JS
<!DOCTYPE html> <html> <head><title>跳轉測試</title> </head> <body> </body> </html><!-- 基礎跳轉 --> <script type="text/javascript">// 在原標簽中進行跳轉到百度首頁// window.location.href="http://www.baidu.com/";// 在新的標簽中進行彈出// window.open('http://www.baidu.com/'); </script><!-- 定時跳轉 --> <script type="text/javascript">setTimeout(jumpurl,5000);function jumpurl(){window.location.href="http://www.baidu.com/";} </script>PHP
<?php$url="http://www.baidu.com/"; header("location:$url"); ?>jQuery
<!DOCTYPE html> <html> <head><title>跳轉頁面</title> </head> <body></body> </html><script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <script type="text/javascript">// 方法一// 跳轉的設置// $(location).attr('href', 'http://www.baidu.com');// // 方法二// 進行跳轉的設置// $(window).attr('location','http://www.baidu.com');// // 方法三// prop設置屬性值$(location).prop('href', 'http://www.baidu.com') </script>?
總結
- 上一篇: 浴室柜子下边不断滴棕色液体,黏糊糊的,检
- 下一篇: 观澜富士康有300块的出租房吗?