摘要: 第一步:安装nodejs 到官网下载页面,下载msi文件,并安装,默认安装在C:\Program Files\nodejs。 更新nodejs时,有时候会提示需要老版本的msi文件,曾经安装后已经删掉了的话,需要到网上搜索下载下来。第二步:安装express 全局安装的命令: npm ins... 阅读全文
posted @ 2015-10-28 09:50 郎涛 阅读(382) 评论(0) 推荐(0) 编辑
摘要: 一、安装1. 下载地址官网:http://phantomjs.org/download.html windows目前最新版本(2015-3-23):phantomjs-2.0.0-windows.zip(19.4 MB)2. 解压到D盘,然后配置windows的系统环境变量PAHT: D:\Pr... 阅读全文
posted @ 2015-03-23 10:44 郎涛 阅读(300) 评论(0) 推荐(0) 编辑
摘要: /*! * jQuery plugin boilerplate */;(function ( $, window, document, undefined ) { var pluginName = "defaultPluginName", //插件名称 defaults = { //默认设置 propertyName: "value" }; // 插件的构造函数 function Plugin( element, options ) { this.element = element; thi... 阅读全文
posted @ 2014-03-25 14:34 郎涛 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 解决安全性问题,主要涉及两点: (1) 前后端约定jsonp请求的js的回调函数名 (2) 服务器端指定返回的数据格式为json (3) 进行referrer验证 ($_SERVER['HTTP_REFERER'] 中的 host,是否在白名单内) 以下是事例代码: 1. 前端js发起ajax跨域j 阅读全文
posted @ 2014-02-14 11:15 郎涛 阅读(1207) 评论(0) 推荐(0) 编辑
摘要: window.onbeforeunload = function(){ if(document.all){ //ie //右上角关闭按钮 或 alt+F4 或 ctrl+w if(event.clientX > document.body.clientWidth || event.clientY < 0 ||event.altKey || event.ctrlKey){ return "关闭窗口"; }else{ return "刷新或跳转"; } }else{ ret... 阅读全文
posted @ 2014-01-07 13:29 郎涛 阅读(1516) 评论(0) 推荐(0) 编辑
摘要: 1. 冒泡排序//冒泡排序(从小到大排列)function bubbleSort(arr){ //一共比较length-1次 for(var i=1, len=arr.length; i0; j--){ //大的排在后面 if(arr[j] arr[j+1]) { var temp = arr[j]; arr[j] = arr[j+1]; arr[j+1] = temp; } console.log( "大换后(index="+... 阅读全文
posted @ 2013-11-19 12:59 郎涛 阅读(302) 评论(0) 推荐(0) 编辑
摘要: 1 ; 2 (function() { 3 /** 4 * 动态加载js文件 5 * @param {string} url js文件的url地址 6 * @param {Function} callback 加载完成后的回调函数 7 */ 8 var _getScript = function(url, callback) { 9 var head = document.getElementsByTagName('head')[0],10 js = document.creat... 阅读全文
posted @ 2013-09-13 16:10 郎涛 阅读(4485) 评论(0) 推荐(0) 编辑
摘要: 一.继承:1. 原型继承(推荐): 参考: Douglas Crockford: http://javascript.crockford.com/prototypal.htmlif (typeof Object.create !== 'function') { Object.create = function (o) { function F() {} F.prototype = o; return new F(); };}var newObject = Object.create(oldObject);2. 类式继... 阅读全文
posted @ 2013-09-03 16:34 郎涛 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 1. 判断是否滚动到页面底部: if($(window).scrollTop() + $(window).height() + 250 >= $(document).height() ){ //滚动到底部的处理 } 阅读全文
posted @ 2013-08-27 15:08 郎涛 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 1. fixed:基本上,手机浏览器对于background-position:fixed属性都不怎么感冒,iPhone Safari浏览器以及WP7上的IE9浏览器都是如此。因此,我们要想在页面上实现效果较好的background-position:fixed效果,基本上只能这样:html, body { height: 100%; overflow: hidden; }2. iOS (iPhone和iPad)的css设置:#content{ -webkit-touch-callout: none; /* 防止拷贝图片 */ -webkit-user-select: none; /*防止.. 阅读全文
posted @ 2013-08-19 10:44 郎涛 阅读(137) 评论(0) 推荐(0) 编辑