I am trying to make a javascript code, but it won't work. First time writing java, and it's a simple thing i'm trying to do, so it's probably a simple solution ;). The code underneath is in the section of my page.
<script language="javascript">
window.onload=function(){
var scherm = $( window ).width();
if (scherm > 971){
var x ="<td class='links'>";
var y ="<td class='rechts'>";
var z ="</td>";
}
else{
var x ="<tr class='links'>";
var y ="<tr class='rechts'>";
var z ="</tr>";
} };
</script>
So firstly I am trying to get the user's browser size. Depending on what that is I want set variable x,y and z. These I would like to echo later on in my html. I have tried that as follows (for x):
<script>document.write(x)</script>
this returns the following error in google chrome:
Uncaught ReferenceError: x is not defined