BOM - Location对象


alert( location.hash );


<script type="text/javascript"> window.onload= function(){ window.onclick= function(){ location.hash= "#666"; } }</script>





alert(location.href);

alert( location.pathname );


alert( location.protocol );

alert( location.search );

<script type="text/javascript"> window.onload =function(){ window.onclick= function(){ location.search= "?xxx=yyy&age=23" } }</script>


<script type="text/javascript"> alert(window.location); alert(location); alert(window.document.location);</script>


<script type="text/javascript"> //alert(window.location); //alert(location); //alert(window.document.location); alert(window.location ==window.document.location);</script>



<head> <metacharset="utf-8"> <title></title> <script> window.onload = function(){ var oBtn = document.getElementById("btn"); oBtn.onclick = function(){ location.assign("http://www.baidu.com"); } }</script> </head><body> <input type="button" value="按钮"id="btn" /></body>

<head> <metacharset="utf-8"> <title></title> <script> window.onload =function(){ var oBtn =document.getElementById("btn"); oBtn.onclick= function(){ //location.assign("http://www.baidu.com"); location.reload() } }</script> </head><body> <input type="button" value="按钮"id="btn" /></body>
<head> <metacharset="utf-8"> <title></title> <script> window.onload =function(){ var oBtn =document.getElementById("btn"); oBtn.onclick= function(){ //location.assign("http://www.baidu.com"); //location.reload(true) location.replace("http://www.baidu.com") } }</script> </head><body> <input type="button" value="按钮"id="btn" /></body>

赞 (0)
