您应该能够执行以下操作:
if (matchMedia) { var mq = window.matchMedia("(max-width: 600px)"); mq.addListener(WidthChange); WidthChange(mq); } function WidthChange(mq) { if (mq.matches) { //Window width is less than or equal to 600px } else { //Window width is greater than 600px } }