Jump to content

Quick question from Newbie.


thecard

Recommended Posts

//Parses Name of Domain

function parseUri (str) {
var	o   = parseUri.options,
	m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
	uri = {},
	i   = 14;

while (i--) uri[o.key[i]] = m[i] || "";

uri[o.q.name] = {};
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
	if ($1) uri[o.q.name][$1] = $2;
});

return uri;
};

parseUri.options = {
strictMode: false,
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
q:   {
	name:   "queryKey",
	parser: /(?:^|&)([^&=]*)=?([^&]*)/g
},
parser: {
	strict: /^(?[^:\/?#]+)?(?:\/\/((?([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?:\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
	loose:  /^(??![^:@]+:[^:@\/]*@)([^:\/?#.]+)?(?:\/\/)?((?([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?:\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
}
};


parseUri.(window.location);
document.write(host);

 

I have found this function (parseUri.) on the internet.

(It parses Urls).

Whats wrong with what I do next:

 

parseUri.(window.location);
document.write(host);

Thanks.

 

 

Link to comment
https://forums.phpfreaks.com/topic/115000-quick-question-from-newbie/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.