Introduction:
Sometimes we has a issue like,assign a web parts based on user screen resolution.In this article,i explained with simple examble “how to resize image based on screen Resolution”.
Main:
The Javascript pre-defined properties screen.width and screen.height helps to capture user screen resolution,
Check this below simple examble,
<SCRIPT language="JavaScript">
if ((screen.width>=1024) && (screen.height>=768))
{
var theImg = document.getElementById('testimg');
theImg.width = "100px";
theImg.height = "100px";
}
else
{
var theImg = document.getElementById('testimg');
theImg.width = "50px";
theImg.height = "50px";
}
//-->
</SCRIPT>
<SCRIPT language="JavaScript"> if ((screen.width>=1024) && (screen.height>=768)) { var theImg = document.getElementById('testimg'); theImg.width = "100px"; theImg.height = "100px"; } else { var theImg = document.getElementById('testimg'); theImg.width = "50px"; theImg.height = "50px"; } //--> </SCRIPT> |
Conclusion:
Hope this helps,
Happy Coding.
I understand the contents are not completely, but otherwise OK.