1
我試圖在Ruby on Rails中的博客應用中添加自定義社交媒體分享按鈕。對於我來說,彈出式窗口將顯示共享「發佈」意味着我想包含Javascript對於我來說很重要。Ruby on Rails社交媒體分享按鈕
不幸的是這碼不起作用:
<!-- Twitter -->
<a oneclick="javascript:window.open('http://twitter.com/share?text=<%= @post.title %>
by Martin Bortowski - &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>
當我點擊一個按鈕,沒有任何反應。我錯過了什麼?有人能幫助我嗎?如果您需要更多信息,請告訴我。
我已經使用了社交分享按鈕的寶石,它的工作完美!我已經使用這個教程https://richonrails.com/articles/adding-social-sharing-buttons-to-your-rails-app – trickydiddy
太棒了! :) –