This should work:
<script>var screenWidth = screen.width;</script>
...
<img src="https://stackoverflow.com/questions/21643920/images/title.png" onload="this.width=screenWidth;" style="margin-top: 3%">
More Related Contents:
- html form that passes information to a variable in javascript [closed]
- Why is the value of my input always empty if I store it in a variable?
- Pass vars to JavaScript via the SRC attribute
- Prepending “http://” to a URL that doesn’t already contain “http://”
- How do I use this JavaScript variable in HTML?
- Get one element title and add this to another div in jquery
- Unescape HTML entities in JavaScript?
- Resizing an image in an HTML5 canvas
- Where to place JavaScript in an HTML file?
- Check if an element contains a class in JavaScript?
- In HTML5, is the localStorage object isolated per page/domain?
- How to prevent a click on a ‘#’ link from jumping to top of page?
- How to disable scroll without hiding it?
- How to pass parameter to function using in addEventListener?
- How to convert a DOM node list to an array in Javascript?
- Set Webkit Keyframes Values Using Javascript Variable
- Getting unparsed (raw) HTML with JavaScript
- Completely lost on how to save extension popup window content
- Set default value for a input file form [duplicate]
- For a push notification, is a websocket mandatory?
- Why does JavaScript navigator.appName return Netscape for Safari, Firefox and Chrome?
- scrollIntoView vs moveToElement
- How to display selected image without sending data to server?
- submit event does not fire if submit initiated programmatically
- universal javascript for set homepage functionality [duplicate]
- Javascript-Setting background image of a DIV via a function and function parameter
- What’s the best way to automatically insert slashes ‘/’ in date fields
- assign color to mouse cursor using CSS
- Change background on button click, using CSS only? [duplicate]
- Set value to currency in