JavaScript»ñÈ¡URL×ÊÔ´Ïê½â

µ¼Óï URL¼´Í³Ò»×ÊÔ´¶¨Î»·û (Uniform Resource Locator, URL)£¬ÍêÕûµÄURLÓÉÕ⼸¸ö²¿·Ö¹¹³É£ºscheme: host:port path?query fragmentscheme:ͨÐÅЭÒ飬³£ÓõÄhttp,ftp,maitoµÈ¡£host:Ö÷»ú£¬·þÎñÆ÷(¼ÆËã»ú)ÓòÃûϵͳ

URL¼´Í³Ò»×ÊÔ´¶¨Î»·û (Uniform Resource Locator, URL)£¬ÍêÕûµÄURLÓÉÕ⼸¸ö²¿·Ö¹¹³É£º
scheme://host:port/path?query#fragment

scheme:ͨÐÅЭÒ飬³£ÓõÄhttp,ftp,maitoµÈ¡£
host:Ö÷»ú£¬·þÎñÆ÷(¼ÆËã»ú)ÓòÃûϵͳ (DNS) Ö÷»úÃû»ò IP µØÖ·¡£
port:¶Ë¿ÚºÅ£¬ÕûÊý£¬¿ÉÑ¡£¬Ê¡ÂÔʱʹÓ÷½°¸µÄĬÈ϶˿ڣ¬ÈçhttpµÄĬÈ϶˿ÚΪ80£¬httpsµÄĬÈ϶˿ÚÊÇ443¡£
path:·¾¶£¬ÓÉÁã»ò¶à¸ö"/"·ûºÅ¸ô¿ªµÄ×Ö·û´®£¬Ò»°ãÓÃÀ´±íʾÖ÷»úÉϵÄÒ»¸öĿ¼»òÎļþµØÖ·¡£
query:²éѯ£¬¿ÉÑ¡£¬ÓÃÓÚ¸ø¶¯Ì¬ÍøÒ³£¨ÈçʹÓÃCGI¡¢ISAPI¡¢PHP/JSP/ASP/ASP.NETµÈ¼¼ÊõÖÆ×÷µÄÍøÒ³£©´«µÝ²ÎÊý£¬¿ÉÓжà¸ö²ÎÊý£¬ÓÃ"&"·ûºÅ¸ô¿ª£¬Ã¿¸ö²ÎÊýµÄÃûºÍÖµÓÃ"="·ûºÅ¸ô¿ª¡£
fragment:ÐÅϢƬ¶Ï£¬×Ö·û´®£¬ÓÃÓÚÖ¸¶¨ÍøÂç×ÊÔ´ÖеÄƬ¶Ï¡£ÀýÈçÒ»¸öÍøÒ³ÖÐÓжà¸öÃû´Ê½âÊÍ£¬¿ÉʹÓÃfragmentÖ±½Ó¶¨Î»µ½Ä³Ò»Ãû´Ê½âÊÍ¡£(Ò²³ÆΪêµã)Õâ¸ö±êÖ¾µã²»ÊÇͳһ×ÊÔ´±êÖ¾·ûµÄÒ»²¿·Ö£¬¶øÊÇÈÃÓû§ä¯ÀÀÆ÷ÔÚ»ñµÃÁËÎļþºóÀ´µ¼º½Óõģ¬Òò´ËËüʵ¼ÊÉϲ»±»Ë͵½·þÎñÆ÷¡£

URL×ÊÔ´ 

ÏÂÃæÎÒÃǾÙÀýÒ»¸öURL£¬È»ºó»ñµÃËüµÄ¸÷¸ö×é³É²¿·Ö¡£
http://bbs.aseoe.com/forum.php?gid=42

window.location.href   ¿ÉÒÔ»ñµÃÕû¸öURL×Ö·û´®£¨ÔÚä¯ÀÀÆ÷ÖоÍÊÇÍêÕûµÄµØÖ·À¸£©¡£
var test = window.location.href;
alert(test);
³ÌÐò·µ»Øhttp://bbs.aseoe.com/forum.php?gid=42

window.location.protocol   ¿ÉÒÔ»ñµÃ URL µÄЭÒ鲿·Ö
var test = window.location.protocol;
alert(test);
³ÌÐò·µ»Ø http:

window.location.host    ¿ÉÒÔ»ñµÃ URL µÄÖ÷»ú²¿·Ö
var test = window.location.host;
alert(test);
³ÌÐò·µ»Ø bbs.aseoe.com

window.location.port   ¿ÉÒÔ»ñµÃ URL µÄ¶Ë¿Ú²¿·Ö
var test = window.location.port;
alert(test);
Èç¹û²ÉÓÃĬÈϵÄ80¶Ë¿Ú(update:¼´Ê¹Ìí¼ÓÁË:80)£¬ÄÇô·µ»ØÖµ²¢²»ÊÇĬÈϵÄ80¶øÊÇ¿Õ×Ö·û¡£

window.location.pathname    »ñµÃ URL µÄ·¾¶²¿·Ö£¨¾ÍÊÇÎļþµØÖ·£©
var test = window.location.pathname;
alert(test);

window.location.search   »ñµÃ²éѯ£¨²ÎÊý£©²¿·Ö£¬³ýÁ˸ø¶¯Ì¬ÓïÑÔ¸³ÖµÒÔÍ⣬ÎÒÃÇͬÑù¿ÉÒÔ¸ø¾²Ì¬Ò³Ã棬²¢Ê¹ÓÃjavascriptÀ´»ñµÃÏàÐÅÓ¦µÄ²ÎÊýÖµ¡£
var test = window.location.search;
alert(test);

window.location.hash     »ñµÃêµã¡£
var test = window.location.hash;
alert(test);
http://www.aseoe.com/ true JavaScript»ñÈ¡URL×ÊÔ´Ïê½â http://www.aseoe.com/show-12-93-1.html report <£¿php echo strlen($content) / 2; ?> URL¼´Í³Ò»×ÊÔ´¶¨Î»·û (Uniform Resource Locator, URL)£¬ÍêÕûµÄURLÓÉÕ⼸¸ö²¿·Ö¹¹³É£ºscheme: host:port path?query fragmentscheme:ͨÐÅЭÒ飬³£ÓõÄhttp,ftp,maitoµÈ¡£host:Ö÷»ú£¬·þÎñÆ÷(¼ÆËã»ú)ÓòÃûϵͳ
TAG:JavaScript URL »ñÈ¡×ÊÔ´
±¾Õ¾»¶Ó­ÈκÎÐÎʽµÄתÔØ£¬µ«ÇëÎñ±Ø×¢Ã÷³ö´¦£¬×ðÖØËûÈËÀͶ¯³É¹û
תÔØÇë×¢Ã÷£º ÎÄÕÂתÔØ×Ô£º°®Ë¼×ÊÔ´Íø http://www.aseoe.com/show-12-93-1.html

[Ç°¶Ë²å¼þÍƼö] Plugin

1 2 3 4
  • jQueryʵÏÖÖð×ÖÖð¾äÏÔʾ²å¼þl-by-l.min.js
  • jQuery´ø·½Ïò¸ÐÖªµÄÊó±ê»¬¹ýͼƬ±ß¿òÌØЧ²å¼þ
  • jQuery HotKeys¼àÌý¼üÅÌ°´ÏÂʼþkeydown²å¼þ
  • ÏìӦʽÎÞÏÞÂÖ²¥jQueryÐýתľÂí²å¼þ
ÏìӦʽÎÞÏÞÂÖ²¥jQueryÐýתľÂí²å¼þ
webÇ°¶Ë¿ª·¢
°®Ë¼×ÊÔ´Íø Copyright 2012-2014 Www.Aseoe.Com All rights reserved.(½úICP±¸13001436ºÅ-1)