1. Create an HTML page, leaving the body section blank other than including a se
ID: 3913628 • Letter: 1
Question
1. Create an HTML page, leaving the body section blank other than including a set of script tags to reference a JavaScript file named prjs11_1.js just before the closing </body> tag. Save the file as pr11_1.html.
Create a JavaScript file and save it as prjs11_1.js. Use this file for steps 3–6.
3. Set a default value for a variable named mywin_width.
4. Assign the value of the window.innerWidth to mywin_width.
5. If the value of mywin_width is greater than or equal to 1000, send the viewer to the URL http://www.scripttheweb.com/js/. Otherwise, send the viewer to the URL http://www.scripttheweb.com/css/ (use the window.location property).
6. Save the JavaScript file and open the HTML file in your Web browser. Try changing the width and then reopening the page with the new width to see which Web page it gives you.
Explanation / Answer
pr11_1.html
<html>
</head>
</head>
<body>
<script type="text/javascript" src="prjs11_1.js" ></script>
</body>
</html>
prjs11_1.js
var mywin_width = 900;
mywin_width = window.innerWidth;
if(mywin_width >= 1000)
window.location = "http://www.scripttheweb.com/js/";
else
window.location = "http://www.scripttheweb.com/css/";
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.