<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>location对象属性</title> <!-- host Sets or returns the host name and port number of the current URL. hash set or return URL (anchor) from the pound sign (#) began. href Sets or returns the full URL. hostname Sets or returns the current URL's hostname. port Sets or returns the port number of the current URL. Set pathname part of the current return path or URL. search Sets or returns from a question mark (?) URL (query part) began. protocol agreement to set or return the current URL. -> </ head > < body > < the INPUT of the type = "the Button" the above mentioned id = "InP" value = "Click" > < Script > console.log (location.host); // host name and port number console.log ( location.hash = " #inp " ); // anchor (#) behind the url console.log (location.href); // complete url console.log (location.hostname); // hostname console.log (location .port); // port number console.log (location.pathname);// path portion url of the console.log (location.search = " ID = 10? " ); // (?) Question mark behind url the console.log (location.protocol); // url protocol </ Script > </ body > </ HTML >
location object properties
Guess you like
Origin www.cnblogs.com/vinson-blog/p/12077422.html
Recommended
Ranking