简体   繁体   中英

Javascript Resize all Images

im trying to resize all images on a page. After googleing 1 day, I ended in the following code:

<script type="text/javascript">
<!--
window.onresize = function(){
var images = document.images;
images.style.width = "100%";
};


-->
</script>

Could someone tell me please, why this wont work? :/

Greets SG

Two points why dont you use css for this, im not sure why you would need to use javascript.

img{width:100%;}

Second in your example your code is commented out and also images creates an array that you will need to loop through seeZoltan Toth answer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM