Java 在Facebook上与我的webapp共享图像
我写这段代码是为了在jsp上显示galleyJava 在Facebook上与我的webapp共享图像,java,javascript,html,ajax,facebook,Java,Javascript,Html,Ajax,Facebook,我写这段代码是为了在jsp上显示galley <c:forEach var="gallery" items="${galleria}"> <div class="uk-overlay uk-margin-top uk-margin-left uk-margin-right uk-margin-bottom"> <a href="data:image/jpeg;base64,${gallery.value}" data-lightbox="roadtr
<c:forEach var="gallery" items="${galleria}">
<div class="uk-overlay uk-margin-top uk-margin-left uk-margin-right uk-margin-bottom">
<a href="data:image/jpeg;base64,${gallery.value}" data-lightbox="roadtrip">
<img id="my_image2" src="data:image/image/jpeg;base64,${gallery.value}" width="300" height="250" alt=""></img>
</a>
<div class="uk-overlay-caption">
<button class="uk-icon-button uk-icon-facebook" type="submit" value="my_image" onclick="fbs_click('my_image2')"/>
<button class="uk-icon-button uk-icon-trash-o" type="submit" value="my_image" onclick="cancella()"/>
</div>
</div>
</c:forEach>
显示的图像从base64编码为jpeg。
我想在Facebook上分享这张图片,我试着写了以下代码
<script>
function fbs_click(id) {
var TheImg = document.getElementById(id);
u = TheImg.src;
console.log(TheImg);
console.log(u);
//t=document.title;
t = TheImg.getAttribute('alt');
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>
功能fbs_单击(id){
var TheImg=document.getElementById(id);
u=最小的src;
控制台日志(TheImg);
控制台日志(u);
//t=文件标题;
t=TheImg.getAttribute('alt');
打开窗户http://www.facebook.com/sharer.php?u='
+encodeURIComponent(u)+'&t='+encodeURIComponent(t),
'共享','工具栏=0,状态=0,宽度=626,高度=436';
返回false;
}
但它不起作用,因为在我看来,它试图共享base64而不是图像url。我如何解决这个问题?谢谢。将图像上传到您的服务器上,然后将图像的url添加到此服务器。我不确定,但这可能会做你的工作