AngularJS मैं जावास्क्रिप्ट में यूआरएल पार्स करने का प्रयास कर रहा हूँ, मैं निम्नलिखित रास्ता मिल गया:जावास्क्रिप्ट में यूआरएल पार्स या
var getLocation = function(href) {
var l = document.createElement("a");
l.href = href;
return l;
};
var l = getLocation("http://example.com:3000/path");
var host = l.host; // example.com
var port = l.port; // 3000
लेकिन मैं एक समस्या का सामना करना पड़ा है, तो इन स्थानों:
http://TLVS0015:3000/cti/YTest // the parse found the port, but its not found the host
http://ctmwe:80/ReportServer/ReportService2010.asmx // the parse found the host, but don't found the port
है वहाँ पार्स करने का कोई और तरीका?
कर 'प्रयास करें l.hostname' – aug
http://james.padolsey.com/javascript/parsing- urls-with-the-dom/ – smarber
यदि आपके पास पहले से ही यूआरएल है, तो क्या आप विभाजन() को विभाजित करने और घटकों को प्राप्त करने के लिए बेहतर नहीं होंगे? (इसके बजाय फिर मेरा उद्देश्य एक वस्तु बनाएं) यदि तारों का उपयोग करने के बजाय ऐसा करने के लिए कोई लाभ है? – atmd