当前位置: 动力学知识库 > 问答 > 编程问答 >

trying to customize Facebook posts within my rails app, like it does on Stackoverflow site

问题描述:

At the bottom of questions on stackoverflow it says:

'Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.'

It's the Facebook part I'm interested in. When the user clicks 'Facebook' they get something like:

The cursor is in the 'Write Something' box, exactly where you want it to be, there's a banner underneath drawing attention to the stackoverflow site...perfect.

In my rails app I can link to Facebook with:

 <div class ="centre_text">Maybe

you'd like to <%= link_to 'ask your friends on Facebook',

"http://www.facebook.com/mypage", :target => "_blank" %> for what

you're looking for? </div>

It goes to the user's page, where they can write a post. But how do I have it like Stackoverflow's, where the 'Write Something' takes up most of the screen, with a 'Share link' button, and how can I put in a banner/detail, like Stackoverflow does?

Any pointers in the right direction would be greatly appreciated.

网友答案:

I am giving you a simple html example, so that you can get idea and customize it according to your need:

Like I want to share a link on facebook, then what I will do is as following:

First create a link:

 <a href="javascript:void(0);"><img class="fShare" data-url="http://google.com/" data-title="luxury sedan" src="facebook.png" width="5" height="11" alt="facebook" /></a>

add some javascript for this link:

 $(document).ready(function() {


   $(".fShare").click(function() {

            window.open(
                    'https://www.facebook.com/sharer/sharer.php?u=' + $(this).attr("data-url") + '&t=' + $(this).attr("data-title"),
                    'facebook-share-dialog',
                    'width=626,height=436');
            return false;

        });

  });
分享给朋友:
您可能感兴趣的文章:
随机阅读: