0

https://jsfiddle.net/6yrr82ph/

i am trying to share this link http://www.domain.com/list.php?id=10&category=food

but on share page i am just getting

http://www.domain.com/list.php?id=10 this link on the share page.

i have a trouble form getting 2nd variable category.

i don't know what wrong is going on. please fix this code

<div class="list text-center" style="margin: 10px;">  

         <a class="item" href="#" onclick="window.open('http://www.facebook.com/sharer.php?u=http://www.domain.com/list.php?id=10&category=food', '_system', 'location=yes'); return false;">    
           facebook share  <i class="fa fa-facebook-square"></i>            </a><br><br>  
       <a class="item" href="#" onclick="window.open('http://twitter.com/share?text=title of blog&url=http://www.domain.com/list.php?id=70&category=food', '_system', 'location=yes'); return false;">                <i class="fa fa-twitter-square"></i>      twitter share     
       </a> 


     </div>
Gautam Jha
  • 1,445
  • 1
  • 15
  • 24
  • possible duplicate of [Sharing a URL with a query string on Twitter](http://stackoverflow.com/questions/6208363/sharing-a-url-with-a-query-string-on-twitter) – Sean Feb 16 '16 at 05:10

2 Answers2

1

You need to encode your url with urlencode.

Try this :

<a class="item" href="#" onclick="window.open('http://www.facebook.com/sharer.php?u=<?php echo urlencode("http://www.domain.com/list.php?id=10&category=food");?>', '_system', 'location=yes'); return false;">
Mr. Engineer
  • 3,522
  • 4
  • 17
  • 34
0

also try this

 <script>
           url='http://www.domain.com/list.php?id=70&category=food';
          url= encodeURIComponent(url);
        </script>

put this encoded url to your code

window.open('http://www.facebook.com/sharer.php?u='+url, '_system', 'location=yes')
Aslam Patel
  • 874
  • 6
  • 19