使用此插件
getResponsiveLayout
函数使用以下参数:
ppw
(必需,整数):在页面从手机竖屏布局切换到手机横屏布局之前,浏览器窗口可以具有的最大宽度(以像素为单位)plw
(必需,整数):在页面从手机横屏布局切换到基于平板电脑布局之前,浏览器窗口可以具有的最大宽度(以像素为单位)tw
(必需,布尔):在页面从平板电脑布局切换到基于桌面的布局之前,浏览器窗口可以具有的最大宽度(以像素为单位)
调用此函数将返回一个字符串,其中包含以冒号 (:
) 分隔的两个部分。根据浏览器的宽度和上述参数,该字符串的第一个部分包含下列值之一:
"phone portrait layout"
"phone landscape layout"
"phone layout"
(适用于不同时具有纵向和横向布局的网站)"tablet layout"
"desktop layout"
返回字符串的第二个部分是浏览器的宽度和高度尺寸。例如:"desktop layout:1243x700"
。
示例
// A visitor accesses your site on their laptop. The browser window is maximized.
// * Your site switches from phone portrait mode to phone landscape mode when the browser width is greater than 500 pixels
// * Your site switches from phone landscape mode to tablet mode when the browser width is greater than 700 pixels
// * Your site switches from tablet mode to desktop mode when the browser width is greater than 1000 pixels
// Sets eVar10 to "desktop layout:1920x937".
s.eVar10 = getResponsiveLayout(500, 700, 1000);
// A visitor accesses your site on their phone.
// * Your site has only a phone mode, a tablet mode, and a desktop mode
// * Your site switches from phone mode to tablet mode when the browser width is greater than 800 pixels
// * Your site switches from tablet mode to desktop mode when the browser width is greater than 1,100 pixels
// Sets eVar10 to "phone portrait layout:720x1280"
s.eVar10 = getResponsiveLayout(800, 800, 1100);
版本历史记录
1.1(2021 年 3 月 19 日)
- 以上下文数据形式添加了版本号。
1.0(2018 年 5 月 2 日)
- 第一版。