i want let the javascript to detect the screen resolution itself because i might have different LCD and each of them are in different size. this is the code temporary i have.
<html>
<head>
<title>ViewImage</title>
<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
setTimeout("location.reload(true);",timeoutPeriod);
}
// -->
</script>
</head>
<body onload="JavaScript:timedRefresh(1);">
<img src = "screenshot.jpeg" width="1014" height="751">
</body>
</html>
i have try to put the javascript into the code
<img src = "screenshot.jpeg" <script type="text/JavaScript">"width ="screen.width </script>>
but it failed. when i open that, i wish it can get the resolution itself at the can anyone help me with this problem ? thanks in advance
In your case, this would suffice:
jsFiddle Demo
Of course this will only do what you want if
bodyis the same size as the viewport. This basically tells the browser that theimgshould be just as big as its parent (in this case thebody).Note: Javascript does not work the way you expect it.
<script>is an HTML element, that lets you embed scripts (Javascript mostly) into your document. You cannot change the HTML source with Javascript on the client side (like you can with PHP, Python, etc. on the server side). You can modify the DOM though.