में मेरी क्वेरी स्ट्रिंग के हिस्से को अनदेखा कर रहा है मेरे पास एक फेसबुक शेयर बटन वाला एक पृष्ठ है। जिस URL को मैं साझा करना चाहता हूं उस पर एक क्वेरी स्ट्रिंग है जिसे मैं जावास्क्रिप्ट के साथ बनाता हूं। यहाँ कैसे मैं साझा करने के लिए URL जनरेट कर रहा हूँ फेसबुक किसी कारण इसकी सब कुछ है कि queryString
चर में बनाया गया था बंद छोड़ने के लिए यूआरएल पकड़ लेता है जब है ..शेयर यूआरएल
queryString = "cup=blue&bowl=red&spoon=green";
//the values of this are actually generated by user input, don't think its important for this example though. So in this example its just a basic string.
siteURL = "http://example.com/?share=1&";
//the url without the query string
sharingURL = siteURL+queryString;
//Combing the domain/host with query string.. sharingURL should = http://example.com?share=1&cup=blue&bowl=red&spoon=green
function FBshare(){
shareURL = siteURL+queryString;
console.log(shareURL);
window.open(
'https://www.facebook.com/sharer/sharer.php?u='+shareURL,
'facebook-share-dialog',
'width=626,height=436');
return false;
}
$(".facebook").bind("click", function(){
FBshare();
});
। तो साझा यूआरएल सिर्फ http://example.com/?share=1
होने के समाप्त होता है। कोई विचार क्यों queryString
चर से बाहर निकल रहा है? सही यूआरएल console.log
में ठीक है, इसके अलावा फेसबुक शेयर.एफ़पी यूआरएल में एक क्वेरी स्ट्रिंग के रूप में (उदाहरण के लिए https://www.facebook.com/sharer/sharer.php?u=http://example.com/?share=1&cup=blue&bowl=red&spoon=green
) .. लेकिन फेसबुक पर वास्तविक लिंक अपूर्ण है।
यहां एक जेएसफ़िल्ड है। http://jsfiddle.net/dmcgrew/gawrv/