在html页面中嵌入动态图像 [英] Embedding a dynamic image in an html page

查看:174
本文介绍了在html页面中嵌入动态图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的家伙,



任何人都可以帮助我完成上述主题。



1)我从applet获取了base64String格式的图像。

2)我将它存储在javascript变量中。

3)HTML页面中有一个按钮,我创建了一个javascript函数,当按下该按钮时将执行该函数。



现在我想在按下时将该图像放在同一个html页面的图像标记中相同的按钮。



var docImage: - 包含Base64字符串

doc_image: - 是图像标记名称。



i尝试了这段代码片段

document.getElementById(''doc_image'')。src =data:image / png,base64,''+ docImage +'';



需要帮助:)

解决方案





而不是:

 document.getElementById('  doc_image)。src =   data:image / png,base64, '  + docImage +'; 



试试这个:

 document.getElementById('  doc_image' )。src =   data:image / png; base64, + docImage; 



希望这会有所帮助。


谢谢老兄,



工作

Dear Guys,

can any one help me to the above topic.

1) I am getting an image in the format base64String from an applet.
2) I am storing that in javascript variable.
3) There is a button in the HTML page, i had created a javascript function which will be executed when that button is pressed.

Now i want to place that image in an image tag in the same html page when pressing the same button.

var docImage :- contains the Base64 string
doc_image : - is the image tag name.

i tried this code snippet
document.getElementById(''doc_image'').src = "data:image/png,base64," '' + docImage +'';

need help :)

解决方案

Hi,

Instead of this:

document.getElementById('doc_image').src = "data:image/png,base64," ' + docImage +';


Try this:

document.getElementById('doc_image').src = "data:image/png;base64,"  + docImage;


Hope this helps.


Thank you dude,

Its working.


这篇关于在html页面中嵌入动态图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆