Click here to Skip to main content
15,918,333 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i tried to change image width with javascript but its not working code is here. Any help?

<script type="text/javascript" language="javascript">
   window.onload = function Resize()
        
        {
                       
                    
            if (document.getElementById('img1').width > 750)
                {
                    document.getElementById('img1').width = '200';
                }
            else
                {
                    
                }
        }
  </script>
Posted

1 solution

Can you try this,

document.getElementById('img1').width = 200;


or this,

MIDL
document.getElementById('img1').style.width = '200px';
 
Share this answer
 
Comments
hiren soni 16-Aug-10 6:23am    
I tried that too but its not working......
Arun Jacob 16-Aug-10 6:50am    
put a debugger; keyword inside if condition and check whether its breaking there.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900