canvas_28 window API

发布时间:2022-07-05 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了canvas_28 window API脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
windowFunc() {
                // window作为全局变量,代表了脚本正在运行的窗口,暴露给 Javascript 代码。
                let uA = navigator.userAgent.toLowerCase();

                // 01. 判断是移动端还是PC端
                VAR mobileOrPc = () => {
                    var ipad = uA.match(/ipad/i) == "ipad";
                    var iphone = uA.match(/iphone os/i) == "iphone os";
                    var midp = uA.match(/midp/i) == "midp";
                    var uc7 = uA.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
                    var uc = uA.match(/ucweb/i) == "ucweb";
                    var andROId = uA.match(/android/i) == "android";
                    var windowsce = uA.match(/windows ce/i) == "windows ce";
                    var windowsmd = uA.match(/windows mobile/i) == "windows mobile";
                    if (!(ipad || iphone || midp || uc7 || uc || android || windowsce || windowsmd)) {
                        this.msg = "PC端";
                    } else {
                        this.msg = "移动端";
                    }
                    console.LOG(uA);
                };

                // 02. 控制当前窗口的关闭
                var isClosed = () => {
                    if (!window.closed) {
                        window.close();
                    }
                };

                // 03. 加密,随机数填充
                var isCrypto = () => {
                    var array = new Uint32Array(10);
                    console.log(array);
                    window.crypto.getRandomValues(array);
                    console.log(array);
                }

                // 04. 本地存储 与 清除 用法同 sessionStorage
                var setLocalStorage = () => {
                    var myStorage = window.localStorage;
                    myStorage.setITem("name", "zk");
                    console.log(myStorage.getItem("name"));
                    myStorage.removeitem("name");
                    console.log(myStorage.getItem("name"));
                    myStorage.clear();
                }

                // 05. 滚动条位置
                var testScroll = () => {
                    // 为了跨浏览器兼容性,请使用 window.pageXOffset 代替 window.scrollX
                    if (window.scrollY > 400) {
                        window.scroll(0, 0);
                    }
                }

                testScroll

                /*
                其他 
                
                设备的物理像素分辨率与 CSS 像素分辨率的比率
                var scale = window.devicePixelRatio;
                
                window.history // windows 页面历史
                window.history.back(); // 返回上一页
                window.history.go(-1); // 返回上一页
                
                window.innerHeight, window.innerWidth // 浏览器窗口的视口的高
                window.outerHeight, window.outerWidth // 整个浏览器窗口的宽高
                
                console.log(window.location); // 当前页面链接
                window.location = "http://www.mozilla.org"; // 当前页面打开URL
                window.location.reload(true); // 强制从服务器重新加载当前页面
                
                window.name // 窗口名字
                window.screen // 返回当前window的screen对象
                
                window.scrollbars.visible // 是否有滚动条
                
                
                方法*********************************************************
                window.alert("123"); // 弹出警告
                
                if (window.confirm("Do you really want to leave?")) // 弹出确认
                
                window.focus() // 将当前窗口放到最前
                
                window.minimize // 窗口最小化
                
                window.moveBy(100, 500); // 窗口移动了 xx xx
                window.moveTo(100, 500); // 窗口移动到 xx xx
                
                window.oPEn("http://www.baidu.COM/", "BAIDU");
                
                window.PRint("文档1"); // 打印
                
                result = window.prompt("你喜欢什么", "默认值"); // 输入框
                
                window.requestAnimationFrame(func) //  告诉浏览器——你希望执行一个动画,并且要求浏览器在下次重绘之前调用指定的回调函数更新动画
                
                window.resizeBy(200, 200); window.resizeTo(100, 100) // 动态调整窗口的大小
                
                window.scroll(0, 500,); // 滚动到多少,功能与 window.scrollTo() 一样, 用法同下 
                window.scrollBy({  // 支持参数:smooth (平滑滚动),instant (瞬间滚动),默认值 auto,效果等同于 instant
                  top: 100,
                  left: 100,
                  behavior: "smooth"
                });
                
                window.stop(); // 停止加载
                
                */
            },

 

脚本宝典总结

以上是脚本宝典为你收集整理的canvas_28 window API全部内容,希望文章能够帮你解决canvas_28 window API所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。