/ / ट्विटर वेब आशय URL एन्कोडिंग काम नहीं कर रहा है - जावास्क्रिप्ट, ट्विटर

ट्विटर वेब आशय URL एन्कोडिंग काम नहीं कर रहा है - जावास्क्रिप्ट, ट्विटर

मुझे नहीं पता कि मैं यहाँ क्या गलत कर रहा हूँ। मैं अपने URL को जावास्क्रिप्ट के साथ एन्कोड करने की कोशिश कर रहा हूं।

https://twitter.com/intent/tweet?text=40%25%20Off%20Prom%20Tuxedo%20Rental&url=http%3A%2F%2Fexample.com%3A5757%2Fcoupon%3Fref_name%3DTest%20Name%26school%3DTest%20School

अगर मैं बाहर ले जाता हूं %20"मेरे URL से तब यह काम करता है ...

https://twitter.com/intent/tweet?text=40%25%20Off%20Prom%20Tuxedo%20Rental&url=http%3A%2F%2Fexample.com%3A5757%2Fcoupon%3Fref_name%3DTestName%26school%3DTestSchool

लेकिन मुझे उन जगहों को वहां रखने की जरूरत है।

यह जावास्क्रिप्ट कोड मेरे पास अभी है ...

var text =  encodeURIComponent("40% Off Prom Tuxedo Rental");
var couponURL = encodeURIComponent("http://example.com/coupon/?ref_name=Test Name&school=Test School");
var twitterURL = "https://twitter.com/intent/tweet?text=";
var twitterURL = twitterURL+text+"&url="+couponURL;

उत्तर:

जवाब के लिए 0 № 1

इस स्थिति में, एक प्रतिशत चिह्न 25% के बराबर होता है, इसलिए यदि आप अपने ट्वीट लिंक में रिक्त स्थान शामिल करना चाहते हैं, तो% 20 के बजाय% 2520 का उपयोग करें। इसलिए जहाँ भी आप% 20 का उपयोग करने जा रहे थे, उसके स्थान पर% 2520 का उपयोग करें।

var text =  "40% Off Prom Tuxedo Rental";
text = text.replace(/s/g, "%2520")