使用css代码可以禁止网页滚动,但是会使浏览器窗口的滚动条消失。而js代码则可以让页面禁止滚动的同时,保留滚动条的显示状态,而且滚动条的位置不变。
javascript代码
var keys = { 37: 1, 38: 1, 39: 1, 40: 1 };
function preventDefault(e) {
e = e || window.event;
if (e.preventDe...
ejs 3.1.5版本,根据网上的视频教程,使用include引用公共部分的html文件时出现错误
引入代码
<%include footer.html%>
报错
SyntaxError: Unexpected identifier in E:\project\nodejs\views\index.html while compiling ejs
If the above...
javascript方法toFixed()可以把Number四舍五入为指定小数位数的数字,但在负数上似乎有问题,把方法提出来重写以兼容负数。
代码可放在方法调用前的任意js文件,或直接放在页面上。
Number.prototype.toFixed = function (s) {
var that = this, changenum, index;
if (this < 0) {
that =...