html - printing an image in HTML5/Javascript -
i new in web development world , had next question
i implement button in html5 print image ( , not whole html page)
i tried code in question print image on website
but got unhandled exception :
0x800a138f - microsoft jscript runtime error : umable value of property 'innerhtml':object null or undefined
can guide me how ?
thanks!
edit : when print , mean prininting on physical printer , , not displaying on screen
something this? whipped up
<!doctype> <html> <body> <button onclick="showimage()">click here image</button> </body> <script type="text/javascript"> function showimage() { var _body = document.getelementsbytagname('body') [0]; var img = document.createelement('img'); //you can replace link image want img.setattribute('src', 'http://i.123g.us/c/cute_teddy/card/109882.gif'); img.setattribute('alt', 'picture'); _body.appendchild(img); } </script> </html>
jsfiddle here
if need help understanding how works, don't hesitate ask. basically, have button , create img tag , set appropriate attributes. 1 time have done that, can append body of html document displays. suggest understanding of dom (document object model) since new web development/javascript.
javascript html html5
No comments:
Post a Comment