前端训练营——JavaScript课件:六:canvas
canvas元素可被用来通过JavaScript(Canvas API 或 WebGL API)绘制图形及图形动画,也就是说canvas标签只是一个图形容器。canvas可以用于动画、游戏画面、数据可视化、图片编辑以及实时视频处理等方面。
canvas元素可被用来通过JavaScript(Canvas API 或 WebGL API)绘制图形及图形动画,也就是说canvas标签只是一个图形容器。canvas可以用于动画、游戏画面、数据可视化、图片编辑以及实时视频处理等方面。
推荐阅读:
Node.js 是一种开源与跨平台的 JavaScript 的运行环境,能够使得javascript脱离浏览器运行。 它是一个可用于几乎任何项目的流行工具,允许我们通过JavaScript和一系列模块来编写服务器端应用和网络相关的应用。
// ==UserScript== // @name 页面自动滚动 // @description 通过使用快捷键实现页面自动滚动 // @match *://*/* // @grant none // ==/UserScript== (function() { 'use strict'; let speed = 0; let speed_num = 1.5; // 修改这个调整滚动速度 let getScrollTop = () => { var scrollTop = 0, bodyScrollTop = 0, documentScrollTop = 0; if (document.body) { bodyScrollTop = document.body.scrollTop; } if (document.documentElement) { documentScrollTop = document.documentElement.scrollTop; } scrollTop = (bodyScrollTop - documentScrollTop > 0) ? bodyScrollTop : documentScrollTop; return scrollTop; } let getWindowHeight = () => { var windowHeight = 0; if (document.compatMode == 'CSS1Compat') { windowHeight = document.documentElement.clientHeight; } else { windowHeight = document.body.clientHeight; } return windowHeight; } let getScrollHeight = () => { var scrollHeight = 0, bodyScrollHeight = 0, documentScrollHeight = 0; if (document.body) { bodyScrollHeight = document.body.scrollHeight; } if (document.documentElement) { documentScrollHeight = document.documentElement.scrollHeight; } scrollHeight = (bodyScrollHeight - documentScrollHeight > 0) ? bodyScrollHeight : documentScrollHeight; return scrollHeight; } setInterval(() => { let bottomFlag = (getScrollTop() + getWindowHeight() == getScrollHeight()) ? true : false; let topFlag = (getScrollTop() == 0) ? true : false; if (bottomFlag || topFlag) { speed = 0; } else { document.documentElement.scrollTop += speed; } }, 5) document.onkeydown = (e) => { e = event || window.event; // 同时按上键与alt键向上滚动 if (e && e.keyCode == 38 && e.altKey) { let bottomFlag = (getScrollTop() + getWindowHeight() == getScrollHeight()) ? true : false; if (bottomFlag) { document.documentElement.scrollTop += -1; } speed -= speed_num; } // 同时按下键与alt键向下滚动 if (e && e.keyCode == 40 && e.altKey) { let topFlag = (getScrollTop() == 0) ? true : false; if (topFlag) { document.documentElement.scrollTop += 1; } speed += speed_num; } // 同时按 CTRL + ALT 键停止滚动 if (e && e.altKey && e.ctrlKey) { speed = 0; } } // 单击页面停止滚动 document.onclick = () => { speed = 0; } // 滑动滚轮页面停止滚动 document.onmousewheel = () => { speed = 0; } document.addEventListener("DOMMouseScroll", () => { speed = 0; }) })();
Ajax(Asynchronous Javascript And XML),即是异步的JavaScript和XML,Ajax其实就是浏览器与服务器之间的一种异步通信方式。它可以异步地向服务器发送请求,在等待响应的过程中,不会阻塞当前页面,在这种情况下,浏览器可以做自己的事情。直到成功获取响应后,浏览器才开始处理响应数据。
JavaScript是一种广泛使用的脚本语言,它允许开发人员为Web应用程序添加交互性和动态性。JavaScript最初是由Netscape Communications在1995年开发的,它已经成为了Web开发的标准之一。
以下是一些推荐:
//ios防止连续点击s
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
jM=jU.substr(-2); //读后面几个
jM=jU.substr(i,1); //从第几个开始,读几个
jM=jU.substring(16,21); //从第几个开始,读到第几个
if(document.getElementsByName("xDcY")){
var form = document.getElementsByName("xDcY");
for(var j=0; j < form.length; j++){