![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Javascript
文章平均质量分 60
diandian82
这个作者很懒,什么都没留下…
展开
-
Web Push Notification By GCM
https://developers.google.com/web/fundamentals/codelabs/push-notifications/server push:const webpush = require('web-push');webpush.setVapidDetails( 'mailto:example@hahaha.org', 'BPC_...原创 2019-03-27 06:46:22 · 528 阅读 · 0 评论 -
构造函数+原型混合方式实现js的继承
function ClassA(sColor){ this.color = sColor; }ClassA.prototype.sayColor = function(){ console.log(this.color);}function ClassB(sColor, sName){ ClassA.call(this, sColor); this.Name = sName;原创 2013-05-26 19:30:36 · 1686 阅读 · 0 评论 -
JS端调用Facebook API
1. 申请Facebook账号2.登陆http://developers.facebook.com/申请APPID3.一定要对你申请的APP设置Site URL 和Site Domain, 如果你需要调试,可以设置为http://localhost/和localhost4.在页面中引用JS, 5.现在就可以调用API了,在调用API之前,必须要进行初始化调用如下函数进行初始化:原创 2012-08-07 14:25:56 · 7389 阅读 · 1 评论 -
最短路径JS版
function GMaze(maze){ // 数组对象,存放迷宫数组 this.MazeSource = maze; // 实例变量 this.Passage=0; //可以走的路 this.Wall=1; //墙,不可以通过 this.Entry=2; // 入口 this.Exit=3; // 出口 this.Visited=4; // 走过的路 this.EntryC原创 2011-12-06 18:41:01 · 2761 阅读 · 3 评论 -
JS中的冒泡与捕获
$(document).ready(function () { var useCapture=false; // Firefox // 这里先要执行捕获阶段事件,然后再执行冒泡阶段事件。 // 执行顺序为:h1clicked capture -> span clicked -> span clicked capture -> h1 clicked // 由于span是事件处理中原创 2011-11-16 10:28:02 · 1308 阅读 · 0 评论 -
JS 中Array中的Sort
如果不自定义排序规则,这些数字字符串会根据字符顺序来排序,不会按照数值大小来排序。下面是如何定义排序规则的例子 var nums = new Array(14, 8, 25, 46, 9,35,23); nums.sort(Compare); alert(nums); function Compare(a原创 2011-06-18 20:06:00 · 879 阅读 · 1 评论 -
To extend jQuery function for gloable usage
1. The following function is to define the static function in JQuery //1. Define gloable function jQuery.foo = function () { alert(This is a test. This is only a test.); }; //原创 2011-06-11 14:13:00 · 777 阅读 · 0 评论 -
Call JS function in Silverlight4
JS and Silverlight4原创 2010-06-12 14:01:00 · 1217 阅读 · 0 评论 -
To get QueryString by using javascript
Request = { QueryString : function(item){ var svalue = location.search.match(new RegExp("[/?/&]" + item + "=([^/&]*)(/&?)","i")); return svalue ? svalue[1] : svalue; } } var sname = Re原创 2010-04-19 15:16:00 · 464 阅读 · 0 评论 -
Preview image when uploading it on client side. Available for IE and FF
1. CSS body{margin:0px;} /*.title { background-image:url(data:image/gif;base64,R0lGODlhAQAcALMAAMXh96HR97XZ98Hf98Xg97DX97nb98Lf97vc98Tg973d96rU97原创 2009-10-31 12:07:00 · 1105 阅读 · 4 评论 -
Hogan.js 使用pratial示例
var hogan = require("hogan.js");var template = hogan.compile('{{#list}}{{foo}}{{> par}}\n{{/list}}');var partial = hogan.compile('/*{{partialData.name}}-{{partialData.age}}*/');var result = templa原创 2013-05-24 15:40:48 · 3366 阅读 · 0 评论 -
示例:js使用正则表达式group来提取字符串中的数据
var linkStr = "/black-mountain/35-cotton-creek-cir-black-mountain-nc-421_537763.html";// 括号表示组。访问可以用group[index]来访问每组的信息var linkRegx = /\/([^\/]+)\/.+-(\d+)_(\d+).html/;var group = linkStr.match(li原创 2013-06-04 16:58:28 · 23953 阅读 · 0 评论 -
What you don't know about template string.
var a = 1, b = 2;var d = 'abc';function tag(strings, ...values) { console.log(strings); // "Hello " console.log(values); // 50 return "Bazinga!";}tag`Hello ${a} World ${b} 2.123 ${d...原创 2018-09-21 11:42:59 · 146 阅读 · 0 评论 -
Implemented Iterator in ES6
class Fruits { constructor() { this.items = []; } add(item) { this.items.push(item); } [Symbol.iterator]() { const elements = this.items; const t...原创 2018-09-21 11:40:12 · 120 阅读 · 0 评论 -
Service worker coding test
var version = '4.0';self.addEventListener('install', function (event) { event.waitUntil(caches.open(version));});self.addEventListener('activate', function (event) { event.waitUntil(new P...原创 2018-04-13 07:06:03 · 256 阅读 · 0 评论 -
自制ES6 Promise
Checked all Promise sample, none of them is in ES6 syntax, this is weird, which age are we now. Simplest verisonclass MyPromise { constructor(fn) { this.doneCallback = null; fn(t原创 2017-12-23 01:51:26 · 211 阅读 · 0 评论 -
Jquery PlugIn for lazy loading items.
//use it with slider control and lister onChange event(function($) { $.fn.sliderthumbs = function(options) { var myOptions = { listener: null }; var $this = $(原创 2017-08-15 16:50:14 · 332 阅读 · 0 评论 -
Working with promise and generators
var Q = require('q');function asyncSquare(n) { var defer = Q.defer(); setTimeout(function(){ if(n>5) defer.reject(888) defer.resolve(n*n); },2000) return defer.promise;}原创 2014-08-23 07:32:05 · 545 阅读 · 0 评论 -
Javascript format numbers
Round to a certain number of placesFor rounding decimals you can use the built-in JavaScript methods toFixed or toPrecision.var num = 10;var result = num.toFixed(2); // result will equal 10.00n转载 2013-07-10 13:13:41 · 618 阅读 · 0 评论 -
use nodemailer to send gmail
1. sudo npm install nodemailer2. Import the following class to your source codevar nodemailer = require("nodemailer");function MailPoster( to, subject, body){ this.from = 'XXXXXXX@gmail.com';原创 2013-06-07 14:07:11 · 1706 阅读 · 0 评论 -
js正则表达式笔记
1. 匹配整个单词列表var reg = /\b(shoes|shirt|pants)\b/;原创 2013-06-06 15:25:04 · 816 阅读 · 0 评论 -
JQUERY插件之条目多行滚动
1. CSS 文件:<!-- ul,li{margin:0;padding:0} #scrollDiv{width:300px;height:100px;min-height:25px;line-height:25px;border:#ccc 1px solid;overflow:hidden} #scrollDiv li{height:2原创 2009-03-28 18:22:00 · 1021 阅读 · 0 评论 -
单条新闻滚动效果
Jquery 代码部分:var n = 0; function ShowNews() { var $firstNode = $(#ulNews>li); if (n == 0) { $firstNode.eq($firstNode.length - 1).fadeOut(原创 2009-03-28 00:41:00 · 1485 阅读 · 0 评论 -
Learn to use Class in Javascript
// // use Arrayvar gsArray = new Array(a,b,c,d);function Button1_onclick() { var a ="";// for(var i=0;i// a += gsArray[i];// document.write(a); // create object1 var原创 2007-01-29 20:57:00 · 760 阅读 · 0 评论 -
javascript技巧搜集。
1.文本框焦点问题onBlur:当失去输入焦点后产生该事件onFocus:当输入获得焦点后,产生该文件Onchange:当文字值改变时,产生该事件Onselect:当文字加亮后,产生该文件(value==) {value=郭强}">点击时文字消失,失去焦点时文字再出现2.网页按钮的特殊颜色style="background-color:rgb(235,207,22)">3.原创 2007-01-25 11:12:00 · 1266 阅读 · 0 评论 -
对表格操作的一个javascript例子
var lastRow = new Array(); function highlightIt(el) { var index = null; if (el.tagName != "TD") { while (el != null) { if ((el.c原创 2006-12-12 16:36:00 · 1032 阅读 · 0 评论 -
修改对象的透明属性,实现淡出效果。
var fadeObj = document.getElementById("Chart_Image");function lowlightit(){ if (fadeObj.filters.alpha.opacity>0) fadeObj.filters.alpha.opacity-=5 else { fadeObj.filters.alpha.op原创 2006-11-29 10:21:00 · 806 阅读 · 0 评论 -
实现下拉菜单显示隐藏的方法。
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/1999/xhtml" lang="gb2312"> body{font-size:14px;color:#6600FF;}ul{margin:0;padding:0;list-style:none;}ul li{padding:2px 0;}#Me原创 2006-11-21 21:16:00 · 4022 阅读 · 0 评论 -
使用层显示实现下拉菜单的显示。
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/1999/xhtml" > Untitled Page // // 取得对象在网页中的绝对位置。function getAbsPosition(obj){ var r = { left: obj.offse原创 2006-11-20 13:50:00 · 1347 阅读 · 0 评论 -
使层的位置始终显示在页面的正中央。
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/1999/xhtml" > 无标题页 function $(id){return document.getElementById(id);}; var div = $("div"); function reset()原创 2006-11-20 13:06:00 · 1129 阅读 · 0 评论 -
自定义的树型菜单
var arrMenus = new Array("title1","title2");var arrDivs = new Array("div1","div2");function doMenu(MenuName){ for (var i=0; i { var div = document.getElementById(arrDivs[i]); var menu = document.get原创 2006-11-20 10:57:00 · 709 阅读 · 0 评论 -
鼠标移动到table,使其在鼠标下面的行高亮显示。
/////////////////////////////////////////////////////////////////////////////////// 功能:这个类使得被附加的表格可以支持行点击高亮// 参数:// tbl: 要附加样式的 table.// selectedRowIndex: 初始高亮的原创 2006-11-16 12:16:00 · 2089 阅读 · 0 评论 -
One point about the return value in Javascript
It is very flexible and easy feature to use return value in Javascript. You can define a return value like a structure in C language.E.G, function makeData()...{ return ...{ Ship: 10原创 2007-06-29 14:25:00 · 670 阅读 · 0 评论 -
Prototype.js 学习笔记
首先是定义类 var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } }}定义了一个class函数作为创建类的模版或者说是原型使用方法var llinzzi= Class.create();llinzzi.prototype = {原创 2007-07-25 11:32:00 · 607 阅读 · 0 评论 -
ASP.NET TreeView 用JS实现节点的单选功能
//用Treeview chekbox节点单选的处理事件 function TreeSingleSelect(treeID, checkNode) { if (!treeID) return; var objs = document.getElementsByTagName("input"); for (va转载 2009-03-20 21:00:00 · 3535 阅读 · 2 评论 -
Json Format example
function ShowJson() { var user = { "username": "andy", "age": 20, "info": { "tel": "123456", "cellph原创 2009-01-23 16:39:00 · 797 阅读 · 0 评论 -
Using JQuery's ajax to call webservice and ashx handler in asp.net
1. Firstly, call the webservice 1) Create Web service using asp.netusing System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services; // This i转载 2009-01-23 16:12:00 · 1529 阅读 · 0 评论 -
JQuery learning note2
$(function() { $(a).click(function() { $(#box).toggle(); $(#box).toggle(3000); $(#box).toggle(slow); // you must define the .bor原创 2009-01-12 17:18:00 · 600 阅读 · 0 评论 -
JQuery leaning note1
$(function() { $(a).click(function() { // the methods of hiding or showing an element // in this section, you can try the following methods and see what happens原创 2009-01-12 11:47:00 · 582 阅读 · 0 评论 -
javascript 实现图片滚动
http://www.w3.org/1999/xhtml" > Picture operation test原创 2008-06-10 12:48:00 · 2083 阅读 · 0 评论