Gautam Jha
Gautam Jha

Reputation: 1473

social sharing links popup not showing correct URL on share page

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>

Upvotes: 0

Views: 230

Answers (2)

Aslam Patel
Aslam Patel

Reputation: 894

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')

Upvotes: 0

Mr. Engineer
Mr. Engineer

Reputation: 3515

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;">

Upvotes: 1

Related Questions