Methods
bottomVisible() → {Boolean}
- Source:
检查页面底部是否可见
Example
bottomVisible(); // false(如果把页面缩放到10%,就为true;页面底部可见)
Returns:
- Type
- Boolean
copyToClipboard(str) → {*}
- Source:
原理:2. document.execCommand('copy')方法,拷贝当前选中内容到剪贴板。
Example
copyToClipboard('哈哈,我被你的tool.copyToClipboard复制出来了')
Parameters:
Name | Type | Description |
---|---|---|
str |
String |
Returns:
- Type
- *
currentURL() → {String}
- Source:
获取当前url
Example
currentURL() // http://localhost:9000/
Returns:
- Type
- String
end()
- Source:
打印结束点
getClientHeight() → {Number}
- Source:
获取窗口可视范围的高度
Example
getClientHeight() // 852
Returns:
窗口可视范围的高度
- Type
- Number
getOffset(el) → {Object}
- Source:
获取当前元素相对于document的偏移量
Example
getOffset(document.getElementById("btn")) // {top: 8, left: 8}
Parameters:
Name | Type | Description |
---|---|---|
el |
HTMLElement |
Returns:
当前元素相对于document的偏移量
- Type
- Object
getPageScrollLeft() → {Number}
- Source:
获取滚动条距左边的高度
Example
getPageScrollLeft() // 0
Returns:
滚动条距左边的高度
- Type
- Number
getPageScrollTop() → {Number}
- Source:
获取滚动条距顶部高度
Example
getPageScrollTop() // 0
Returns:
滚动条距顶部高度
- Type
- Number
getPageViewWidth() → {Number}
- Source:
获取窗口可视范围宽度
Example
getPageViewWidth() // 274
Returns:
窗口可视范围宽度
- Type
- Number
getPageWidth() → {Number}
- Source:
获取窗口宽度
Example
getPageWidth() // 274
Returns:
窗口宽度
- Type
- Number
getScrollPosition(elopt) → {Object}
- Source:
返回当前滚动条位置
Example
// scrollLeft和scrollTop是IE8可兼容
getScrollPosition() // {x: 0, y: 775}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
el |
* |
<optional> |
window
|
Returns:
当前滚动条位置
- Type
- Object
getViewportOffset() → {Object}
- Source:
获取窗口尺寸
Example
getViewportOffset() // {w: 291, h: 852}
Returns:
窗口尺寸
- Type
- Object
httpsRedirect()
- Source:
http跳转https(当前url如果是http会帮你转https)
Example
httpsRedirect()
isBrowser() → {Boolean}
- Source:
检查是否为浏览器环境
Example
isBrowser(); // true
Returns:
- Type
- Boolean
isBrowserTabFocused() → {*}
- Source:
检查当前标签页是否活动
Example
isBrowserTabFocused(); // true
Returns:
- Type
- *
openWindow(url, windowName, width, height)
- Source:
打开一个窗口
Example
openWindow("https://juejin.im/post/5e6cf42bf265da57397e3694","haha",700,1000)
Parameters:
Name | Type | Description |
---|---|---|
url |
String | 跳转链接 |
windowName |
String | 窗口名 |
width |
Number | 宽度 |
height |
Number | 高度 |
smoothScroll(elementopt, isEnd)
- Source:
滚动到指定元素区域的最下/最上
Example
smoothScroll() // 滚动到底部,默认是document.documentElement
smoothScroll('#aaa') // 滚动到id为aaa
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
element |
HTMLElement |
<optional> |
document.documentElement
|
指定元素 |
isEnd |
Boolean |
false
|
方向 传true向上平滑,不传就是向下(默认) |
start()
- Source:
打印开始点