JavaScript document.write display image
In addition to outputting text strings, the feature of JavaScript document.write can also output content that contains HTML tags. This article is to use this feature to enable JavaScript to also output images to web pages, allowing traditional HTML img image insertion methods There are richer changes. The actual part must be combined with JavaScript document.write and HTML img tags. Almost all mainstream browsers support document.write to display pictures. Please see the two basic syntaxes required. .
Document.write and HTML img basic syntax
Script | grammar structure |
Document.write | document.write('Write the text you want to present here'); |
HTML img | <img src="Picture URL put here"> |
As long as these two grammars are combined, images can be easily output to web pages via JavaScript document.write .
JavaScript document.write display image example
document.write('<img src="images/logo.png">');
</script>
Post a Comment
0 Comments