简体   繁体   中英

Rails 3: How to store screen resolution?

I want to store user's screen resolution in database when user login. How to detect and store it to database when user login?

Read it with JavaScript (browsers don't send screen resolution information by default, so it isn't available to Ruby or anything else server side unless you make it so), then generate a hidden input , set the name and value based on the data you've gathered, then add it to the form containing the username and password inputs.

Oh, and you might find the window size more useful than the screen resolution. Not everybody maximizes their windows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM