問題:
I am trying to write a JavaScript function to get the current browser width.我正在嘗試編寫一個 JavaScript 函數來獲取當前瀏覽器的寬度。
I found this one:我找到了這個:
javascript:alert(document.body.offsetWidth);
But its problem that it fail if the body has width 100%.但它的問題是,如果主體的寬度爲 100%,它就會失敗。
Is there any other better function or a workaround?還有其他更好的功能或解決方法嗎?
解決方案:
參考一: https://en.stackoom.com/question/4MDf參考二: https://stackoom.com/question/4MDf