location





js/script.js
  • function funAssign() {
  •  // location.assign(url)
  •  location.assign('http://mail.ru');
  • }
  •  
  • function funMake() {
  •  // location.href
  •  document.write(location.href + '<br />');
  •  
  •  // location.toString()
  •  document.write(location.toString() + '<br />');
  •  
  •  // location.pathname
  •  document.write(location.pathname + '<br />');
  •  
  •  // location.protocol
  •  document.write(location.protocol + '<br />');
  •  
  •  // location.host
  •  document.write(location.host + '<br />');
  •  
  •  // location.hostname
  •  document.write(location.hostname + '<br />');
  •  
  •  // location.port
  •  document.write(location.port + '<br />');
  • }
  • function funAssign() {
  •  // location.assign(url)
  •  location.assign('http://mail.ru');
  • }
  •  
  • function funMake() {
  •  // location.href
  •  document.write(location.href + '<br />');
  •  
  •  // location.toString()
  •  document.write(location.toString() + '<br />');
  •  
  •  // location.pathname
  •  document.write(location.pathname + '<br />');
  •  
  •  // location.protocol
  •  document.write(location.protocol + '<br />');
  •  
  •  // location.host
  •  document.write(location.host + '<br />');
  •  
  •  // location.hostname
  •  document.write(location.hostname + '<br />');
  •  
  •  // location.port
  •  document.write(location.port + '<br />');
  • }


index.html
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  •  <script>
  •   funMake();
  •  </script>
  •  <br />
  •  <a href="javascript:funAssign()">mail.ru</a>
  • </body>
  • </html>
  • <!DOCTYPE html>
  • <html>
  • <head>
  •  <meta charset="utf-8" />
  •  <title>New Page</title>
  •  <script src="js/script.js"></script>
  • </head>
  • <body>
  •  <script>
  •   funMake();
  •  </script>
  •  <br />
  •  <a href="javascript:funAssign()">mail.ru</a>
  • </body>
  • </html>