Closed Bug 186551 Opened 23 years ago Closed 23 years ago

JS screen.width returns wrong value

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows 2000
defect
Not set
normal

Tracking

()

VERIFIED DUPLICATE of bug 62395

People

(Reporter: robert.graf, Assigned: jst)

References

()

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130 I'm using this little JavaScript to set a 'nice' font size and margin, but for example, for the 'real' screen width 1152 (also 1280?), JS screen.width returns 1024. IE & Opera are working correct. <script type="text/javascript"> <!-- var swx = screen.width; var shx = screen.height; // Default for 17 inch, 1024 x 768 var fsx = "11"; var mlp = "2.5"; var mrp = "14.5"; if (swx >= 1600) {fsx = "15"; mlp = "2.5"; mrp = "15.5";} else if (swx >= 1280) {fsx = "14"; mlp = "2.5"; mrp = "15.5";} else if (swx >= 1152) {fsx = "12"; mlp = "2.5"; mrp = "15.5";} else if (swx >= 1024) {fsx = "11"; mlp = "2.5"; mrp = "14.5";} else if (swx >= 800) {fsx = "10"; mlp = "1.5"; mrp = "1.5";} else if (swx >= 640) {fsx = "9"; mlp = "1.5"; mrp = "1.5";} document.write('<div style="margin-left:', mlp, '%; margin-right:', mrp, '%; font-size:', fsx, 'px;">'); //--> </script> Reproducible: Always Steps to Reproduce: 1. Set the screen width in your system to 1152. 2. Go to the link. Actual Results: The font size is 11 and not 12. Expected Results: screen.width (and maybe also screen.height) should return the correct values from the system. I know each user should set his own font-size in the browser :-) but it should work!
I play a little with this bug (btw, it is enough to put javascript:alert(screen.width) in URL field) and found, that if user change screen and NOT RESTART mozilla, than width and height report old value, but if user restart it -- correct values appeared. I propose that screen parametes should be detected when screen methods working, not at start of Mozilla.
*** This bug has been marked as a duplicate of 62395 ***
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
verified.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.