-1

This is the code:

<div id="screen1">You do not have javascript enabled.</div>
<div id="screen2">You do not have javascript enabled.</div>
<script>
   document.getElementById("screen1").innerHTML = return window.screen.availHeight;
   document.getElementById("screen2").innerHTML = return window.screen.availWidth;
</script>

The output for both screen1 and screen2 is You do not have javascript enabled., I thought this way would work because I used this before and it worked:

<div id="locale">You do not have javascript enabled.</div>
<script>document.getElementById("locale").innerHTML = getLang();</script>   
1
  • 1
    remove the return from the return window.screen.availHeight portion Commented Feb 4, 2016 at 18:52

2 Answers 2

2

If you remove the return keyword, everything will work as normal. Since you're not defining/inside of a function, the return keyword is out of place.

document.getElementById("screen1").innerHTML = window.screen.availHeight;
document.getElementById("screen2").innerHTML = window.screen.availWidth;
<div id="screen1">You do not have javascript enabled.</div>
<div id="screen2">You do not have javascript enabled.</div>

Sign up to request clarification or add additional context in comments.

Comments

0

document.getElementById("screen1").innerHTML = window.screen.availHeight;
document.getElementById("screen2").innerHTML = window.screen.availWidth;
<!DOCTYPE html>
<html>
<head>
  <title>My HTML</title>
  <meta charset="UTF-8">
</head>
<body>
<div id="screen1">You do not have javascript enabled.</div>
<div id="screen2">You do not have javascript enabled.</div>
</body>
</html>

Try this without return

document.getElementById("screen1").innerHTML = window.screen.availHeight;
document.getElementById("screen2").innerHTML = window.screen.availWidth;

Output from my pc

<div id="screen1">860</div>
<div id="screen2">1440</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.