Detect screen width for multiple monitors

时光怂恿深爱的人放手 提交于 2019-11-30 12:44:05

Try looking at window.innerWidth (the width of the web page on screen) instead of window.screen.width.

Thanks for your response duskwuff. Helped me compile the below function which solved the problem for me.

function getBrowserWith()
{
    if(($.browser.msie == true && $.browser.version == '9.0') || $.browser.webkit == true || $.browser.mozilla == true)
        return window.innerWidth;
    else if(($.browser.msie == true) && ($.browser.version == '7.0' || $.browser.version == '8.0'))
        return document.documentElement.clientWidth;
    else
        return screen.width;
}

Important notes

  1. jQuery 1.4+ is required
  2. Note that the above function has been tested only for IE7+, FF7+ & Chrome16+ browsers.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!