Detecting screen resolution in javascript?

djs's icon

Anybody know how to detect screen resolution in javascript?

From looking about the web I've found that for web programming purposes you can use the "screen" object (screen.width, screen.height etc) but this does not appear to work in the max js object.

Any suggestions?

Cheers,

David

PS appologies for double posting - accidentally replied to a related post which I didn't realise was in the jitter forum - hence the re-post here.

swieser1's icon

Not sure if you can do it in js, but you can always just use the jit.displays object, and send the info into your js.

djs's icon

Yeah, I probably will have to do that, but I was hoping there would be a simpler way - there will be timing implications in my programme if i have to do it outside js - and that always makes my brain hurt.

Thanks anyway.

David

johnpitcairn's icon

Just use [screensize] at loadbang to send the data to your js, and store it there for re-use?

Or are you hoping to detect screen resolution changes made by the user?

djs's icon

Nope, not planning on detecting a changing screen resolution. Using [screensize] is already my plan B, and is looking more and more like my only option.

In fact, hang it all, that's what I'm going to do.

I'm a little surprised, though, that js doesn't work with all standard javascript web objects... oh well, you can't have everything.

THanks for all the advice.

D