Full version: jsB@nk » Snippet » Scaling image accord to Window size
URL: https://www.javascriptbank.com/scaling-image-accord-to-window-size.html
Use JavaScript to Scale an Image According to Window Size Sometimes you need to resize an image according to the window's size. You can do this by setting the image width and height as 100 percent inside the <img> tag. IE then resizes the image according to the window's size.You can also do this with JavaScript, using document.body.clientWidth
and document.body.clientHeight
. These return the active window width and height. On_Load sets the image width and height. When the window is resized, width.history.go(0) refreshes the page.
Full version: jsB@nk » Snippet » Scaling image accord to Window size
URL: https://www.javascriptbank.com/scaling-image-accord-to-window-size.html
<script language="javascript">function ScaleSize(){document.getElementById("imgTag").style.width = document.body.clientWidth;document.getElementById("imgTag").style.height = document.body.clientHeight;}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<body onload="javascript:ScaleSize();" onresize="history.go(0)"><img id="imgTag" src="../image/logojs.gif"></body><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->