I would like to configure the onClick function for the image on my new website that launches Facebook.
Here are some snippets of code that can help you understand what I'm talking about.
<div id="mImageBox"> <img id='my_image' src='' width="auto" height="auto"/> </div>
The src image is empty because it is injected by another JavaScript function using "my_image"
so I tried to configure the onClick function using this method:
<script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script> <div id="mImageBox"> <a rel="nofollow" href="http://www.facebook.com/share.php?u=<;url>" onclick="return fbs_click()" target="_blank"><img id='my_image' src='' width="auto" height="auto"/></a> </div>
The onClick function works well, however it links to the page where img is located, not img itself!
Do you have any suggestions for me?
javascript css image onclick
iGio90
source share