thecard Posted July 16, 2008 Share Posted July 16, 2008 //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 More sharing options...
Xurion Posted July 16, 2008 Share Posted July 16, 2008 All you're doing at the end of the script is trying to write the host variable to the screen. From what I can see, the host variable isn't set, so it appears nothing is written. Link to comment https://forums.phpfreaks.com/topic/115000-quick-question-from-newbie/#findComment-591531 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.