2017-03-28 103 views
1

我試圖在Ruby on Rails中的博客應用中添加自定義社交媒體分享按鈕。對於我來說,彈出式窗口將顯示共享「發佈」意味着我想包含Javascript對於我來說很重要。Ruby on Rails社交媒體分享按鈕

不幸的是這碼不起作用:

<!-- Twitter --> 
    <a oneclick="javascript:window.open('http://twitter.com/share?text=<%= @post.title %> 
    by Martin Bortowski - &amp;url=<%= url_for([@post, {only_path: false}]) %>', 
    '_blank', 'width=800, height=500, top=200, left=300');void(0);"><i class="fa fa-twitter"></i></a> 

    <!-- Facebook --> 
    <a oneclick="javascript:window.open('http://facebook.com/sharer.php?u=<%= url_for([@post, {only_path: false}]) %>', 
    '_blank', 'width=800, height=500, top=200, left=300');void(0);"><i class="fa fa-facebook"></i></a> 

    <!-- Google Plus --> 
    <a oneclick="javascript:window.open('https://plus.google.com/share?url=<%= url_for([@post, {only_path: false}]) %>', 
    '_blank', 'width=800, height=500, top=200, left=300');void(0);"><i class="fa fa-google-plus"></i></a> 

當我點擊一個按鈕,沒有任何反應。我錯過了什麼?有人能幫助我嗎?如果您需要更多信息,請告訴我。

回答