Công Nghệ

Get current URL with jQuery?

java-script provides many methods to retrieve current URL which is displayed in browser’s address bar.

Test URL :

Bạn đang xem: window.location jquery

http:// taobontreem.com/questions/5515310/get-current-url-with-jquery/32942762 ? rq=1&page=2&tab=active&answertab=votes # 32942762 taobontreem.com(); taobontreem.com(‘URL Object ‘, webAddress); taobontreem.com(‘Parameters ‘, param_values);

Function:

var webAddress = {}; var param_values = {}; var protocol = ”; var resourceAddress = { fullAddress : function () { var addressBar = taobontreem.com; if ( addressBar != ” && addressBar != ‘undefined’) { webAddress[ ‘href’ ] = addressBar; } }, protocol_identifier : function () { taobontreem.comAddress(); protocol = taobontreem.comace(‘:’, ”); if ( protocol != ” && protocol != ‘undefined’) { webAddress[ ‘protocol’ ] = protocol; } }, domain : function () { taobontreem.comocol_identifier(); var domain = taobontreem.comname; if ( domain != ” && domain != ‘undefined’ && typeOfVar(domain) === ‘string’) { webAddress[ ‘domain’ ] = domain; var port = taobontreem.com; if ( (port == ” || port == ‘undefined’) && typeOfVar(port) === ‘string’) { if(protocol == ‘http’) port = ’80’; if(protocol == ‘https’) port = ‘443’; } webAddress[ ‘port’ ] = port; } }, pathname : function () { taobontreem.comin(); var resourcePath = taobontreem.comname; if ( resourcePath != ” && resourcePath != ‘undefined’) { webAddress[ ‘resourcePath’ ] = resourcePath; } }, params : function () { taobontreem.comname(); var v_args = taobontreem.comtring(1).split(“&”); if ( v_args != ” && v_args != ‘undefined’) for (var i = 0; i < taobontreem.comth; i++) { var pair = v_args[i].split(“=”); if ( typeOfVar( pair ) === ‘array’ ) { param_values[ decodeURIComponent( pair[0] ) ] = decodeURIComponent( pair[1] ); } } webAddress[ ‘params’ ] = param_values; }, hash : function () { taobontreem.comms(); var fragment = taobontreem.comtring(1); if ( fragment != ” && fragment != ‘undefined’) webAddress[ ‘hash’ ] = fragment; } }; function typeOfVar (obj) { return {}.toString.call(obj).split(‘ ‘)[1].slice(0, -1).toLowerCase(); }

  • protocol « Web-browsers use Internet Protocol by following some rules for communication between WebHosted Applications and Web Client(Browser). (http = 80, https (SSL) = 443, ftp = 21, etc.)

EX: With default port numbers

Xem thêm: List camera360 cho laptop win7

XEM THÊM:  Top lỗi league of legends skinned.launcher has stopped working

<protocol>//<hostname>:<port>/<pathname><search><hash> taobontreem.com:443/wiki/Pretty_Good_Privacy taobontreem.com:80/

  • (//) « Host is the name given to an end-point(machine on which resource lives) on the Internet. taobontreem.com – DNS IP Address of an Application (OR) localhost:8080 – localhost

Domain names are which you register by the rules and procedures of the Domain Name System(DNS) tree. DNS servers of someone who manages your domain with IP-Address for addressing purposes. In DNS server hierarchy the Root name of an taobontreem.com is com.

gTLDs – com « stackoverflow (OR) in « co « google

Local system you have to maintain domain’s which are not PUBLIC in Host Files. taobontreem.com « localhsot – subdomain(web-server), taobontreem.com – maindomain(Proxy-Server). taobontreem.com 172.89.23.777

  • (/) « The path gives info about the specific resource within the host that the Web client wants to access
  • (?) « An optional query is to pass a sequence of attribute-value pairs separated by a delimiter(&).
  • (#) « An optional fragment is often an id attribute of a specific element, and web browsers will scroll this element into view.

If parameter has an Epoch ?date=1467708674 then use.

var epochDate = 1467708674; var date = new Date( epochDate );

Xem thêm: chuột cảm ứng laptop bị lỗi không click được

URL

Authentication url with username:password, If usernaem/password contains @ symbol like:

Username = `my_email@gmail` Password = `Yash@777`

then You need to URL encode the @ as %40. Refer…

http://my_email%40gmail.com:Yash%40777@taobontreem.com

encodeURI() (vs) encodeURIComponent() example

var testURL = “http:my_email@gmail:Yash777@//stackoverflow.com?tab=active&page=1#32942762”; var Uri = “/:@?&=,#”, UriComponent = “$;+”, Unescaped = “(-_.!~*’)”; // Fixed var encodeURI_Str = encodeURI(Uri) +’ ‘+ encodeURI( UriComponent ) +’ ‘+ encodeURI(Unescaped); var encodeURIComponent_Str = encodeURIComponent( Uri ) +’ ‘+ encodeURIComponent( UriComponent ) +’ ‘+ encodeURIComponent( Unescaped ); taobontreem.com(encodeURI_Str, ‘n’, encodeURIComponent_Str); /* /:@?&=,# +$; (-_.!~*’) %2F%3A%40%3F%26%3D%2C%23 %2B%24%3B (-_.!~*’) */

XEM THÊM:  Những bài thực hành công nghệ 11

Xem thêm: xem mat khau wifi win 8

Related Articles

Trả lời

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Back to top button