Nov 10, 2011

How to get browser screen settings and apply it to page controls


You can use the JavaScript, suppose the control type is <image>, see the code below:
<html>
<body>
<input onclick="resizeImage()"/>
<img src="http://www.microsoft.com/library/toolbar/3.0/images/banners/ms_masthead_ltr.gif"  id="Img1"  />
<script language="JavaScript">
    var winWidth = 0;
    var winHeight = 0;
    function resizeImage(){
    var img=document.getElementById("testImage")
    if (window.innerWidth)
           winWidth = window.innerWidth;
     else if ((document.body) && (document.body.clientWidth))
           winWidth = document.body.clientWidth;
     if (window.innerHeight)
           winHeight = window.innerHeight;
     else if ((document.body) && (document.body.clientHeight))
           winHeight = document.body.clientHeight;  
     if (document.documentElement  && document.documentElement.clientHeight && 
                                          document.documentElement.clientWidth)
     {
         winHeight = document.documentElement.clientHeight;
         winWidth = document.documentElement.clientWidth;
     }
     img.width= winHeight;
     img.width= winWidth;
    }
</script>
</body>
</html>
Please remove the control style if it is present. 
Related posts:

0 comments:

Post a Comment

Your comments:

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More