亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

JavaScript Window Location

JavaScript Window Location

The window.location object is used to obtain the address (URL) of the current page and redirect the browser to the new page.

Window Location

window.location object can be written without using the window prefix. Some examples:

Some examples:

location.hostname Returns the domain name of the web host

location.pathname Returns the path and file name of the current page

location .port Returns the port of the web host (80 or 443)

location.protocol Returns the web protocol used (http:// or https://)

Window Location Href

location.href property returns the URL of the current page.

Example

Return the entire URL (of the current page):

<script>
document.write(location.href);
</script>

The output of the above code is:

http://php.cn/js/js-window-location.html

Window Location Pathname

The location.pathname property returns the pathname of the URL.

Example

Return the path name of the current URL:

<script>
document.write(location.pathname);
</script>

The output of the above code is:

/js/js-window-location.html

Window Location Assign

location. The assign() method loads a new document.


Continuing Learning
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <head> <script> function newDoc(){ window.location.assign("http://www.ask.php.cn") } </script> </head> <body> <input type="button" value="加載新文檔" onclick="newDoc()"> </body> </html>
submitReset Code