Home » WordPress » Display the width of your device’s screen in a WordPress Page

Display the width of your device’s screen in a WordPress Page

Simply insert this piece of JavaScript where you would like to see the width displayed. This is useful to test a devices resolution.

<div id="widthInfo">
</div>

<script>
    var x=screen.width;
    var para = document.createElement("P");
    var t = document.createTextNode(x);
    para.appendChild(t);
    document.getElementById("widthInfo").appendChild(para);
</script>

Using “document.write(screen.width)” is not going to work by the way.

Support