随笔分类 -  javascript

json转字符串
摘要:function json2str(o) { function isArray(o) { return Object.prototype.toString.call(o) === '[object Array]'; } var arr = []; var fmt = function(s) { var type = typeof s; if (type == 'object' && s != null){ return self.json2str(s); } if(type === "number"){ return s; } 阅读全文

posted @ 2012-06-23 11:33 kxdhm 阅读(189) 评论(0) 推荐(0)

window.onerror不会死循环
摘要:<script>(function(){ window.onerror = function(msg,url,line){ var c = {}; if(!window.onerror.xxx){ try{ version = c.c.c;//出错,会不会触发window.onerror?调试证明,不会循环触发 }catch(e){ window.onerror.xxx = true;//防止死循环 } } ... 阅读全文

posted @ 2012-06-02 09:58 kxdhm 阅读(203) 评论(0) 推荐(0)

js遍历属性,返回字符串
摘要:拿到别人的代码,一个对象属性值非常复杂,但是在某些情况下有没有调试工具,如何办?如何查看对象的所有属性?一下代码可以解决这个问题function WalkP(obj,showString){ if(!WalkP.isArray(obj)){ var str = "{\n"; for(var o in obj){ var value = "'"+(typeof obj[o]).toUpperCase()+"'"; if(WalkP.isArray(obj[o])){//濡傛灉涓烘暟缁? ... 阅读全文

posted @ 2012-04-01 16:06 kxdhm 阅读(681) 评论(0) 推荐(0)

IE6/7 字符串 数组方式获取字符 不支持
摘要:var string="asdf"alert(string[0]); IE 6 7 下为undefined 阅读全文

posted @ 2012-03-15 11:52 kxdhm 阅读(178) 评论(0) 推荐(0)

javascript tea加密
摘要:转自http://www.movable-type.co.uk/scripts/tea-block.html/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - *//* Block TEA (xxtea) Tiny Encryption Algorithm implementation in JavaScript *//* (c) Chris Veness 2002-2010: www.movable... 阅读全文

posted @ 2012-03-12 17:02 kxdhm 阅读(1263) 评论(0) 推荐(0)

一个不容易觉察到的js错误,function () {}(function () {}) is not a functio
摘要:var asdf = function(){} (function(){ })()解决方案:var asdf = function(){}; (function(){ })() 阅读全文

posted @ 2012-03-06 19:30 kxdhm 阅读(204) 评论(0) 推荐(0)

zepto.js 手机web开发 js 框架,类似于jquery
摘要:// Zepto.js// (c) 2010, 2011 Thomas Fuchs// Zepto.js may be freely distributed under the MIT license.(function(undefined){ if (String.prototype.trim === undefined) // fix for iOS 3.2 String.prototype.trim = function(){ return this.replace(/^\s+/, '').replace(/\s+$/, '') }; // For iO. 阅读全文

posted @ 2012-02-21 18:37 kxdhm 阅读(2484) 评论(0) 推荐(0)

iscroll.js 触屏手机web-kit浏览器滚动效果代码库
摘要:/**! * iScroll v4.1.8 ~ Copyright (c) 2011 Matteo Spinelli, http://cubiq.org * Released under MIT license, http://cubiq.org/license */(function(){var m = Math, vendor = (/webkit/i).test(navigator.appVersion) ? 'webkit' : (/firefox/i).test(navigator.userAgent) ? 'Moz' : 'opera' 阅读全文

posted @ 2012-02-21 18:34 kxdhm 阅读(2490) 评论(0) 推荐(0)

HTML5 Geolocation
摘要:<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Geolocation API</title></head><body><p><script>if(navigator.geolocation){ navigator.geolocation.getCurrentPosition( f 阅读全文

posted @ 2012-02-10 18:11 kxdhm 阅读(224) 评论(0) 推荐(0)

手机端userAgent
摘要:iphone3gs自带的Safari浏览器Mozilla/5.0 (iPhone:U;CPU iPhone OS 4_1 like Mac OS X;zh-cn) AppleWebKit/532.9(KHTML,like Gecko)Version/4.0.5 Mobile/8B117 Safari/6531.22.7QQ浏览器MQQBrowser/2801Mozilla/5.0 (iPhone:U;CPU iPhone OS 4_1 like Mac OS X;zh-cn) AppleWebKit/532.9(KHTML,like Gecko)Version/4.0.5 Mobile/8B1 阅读全文

posted @ 2012-02-07 12:40 kxdhm 阅读(777) 评论(1) 推荐(0)

javascript RSA算法(三)
摘要:// RSA, a suite of routines for performing RSA public-key computations in// JavaScript.//// Requires BigInt.js and Barrett.js.//// Copyright 1998-2005 David Shapiro.//// You may use, re-use, abuse, copy, and modify this code to your liking, but// please keep this header.//// Thanks!// // Dave Shapir 阅读全文

posted @ 2012-02-02 18:09 kxdhm 阅读(1344) 评论(0) 推荐(0)

javascript RSA算法(二)
摘要:// BigInt, a suite of routines for performing multiple-precision arithmetic in// JavaScript.//// Copyright 1998-2005 David Shapiro.//// You may use, re-use, abuse,// copy, and modify this code to your liking, but please keep this header.// Thanks!//// Dave Shapiro// dave@ohdave.com// IMPORTANT THING 阅读全文

posted @ 2012-02-02 18:08 kxdhm 阅读(667) 评论(0) 推荐(0)

javascript RSA算法
摘要:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html lang="en"><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><meta name="Author" content="Dave Shapiro"><meta n 阅读全文

posted @ 2012-02-02 18:07 kxdhm 阅读(4246) 评论(0) 推荐(0)

javascript DES算法(二)
摘要:<!DOCTYPE html><html lang="zh-cn"><head><meta http-equiv="content-type" content="text/html;charset=utf-8"><title>DES算法</title></head><body><script>//Javascript version//Paul Tero, July 2001//http://www.shopable.co.uk 阅读全文

posted @ 2012-02-02 10:37 kxdhm 阅读(398) 评论(0) 推荐(0)

javascript DES算法(一)
摘要:<!DOCTYPE html><html lang="zh-cn"><head><meta http-equiv="content-type" content="text/html;charset=utf-8"><title>DES算法-Code by 梅雪香</title><style type="text/css">textarea{width:600px; height:150px;}body{font-size:12px}i 阅读全文

posted @ 2012-02-02 10:04 kxdhm 阅读(900) 评论(0) 推荐(0)

javascript md5加密算法
摘要:用法:md5Value = hex_md5("asdfasdf")<script>/** A JavaScript implementation of the RSA Data Security, Inc. MD5 Message* Digest Algorithm, as defined in RFC 1321.* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet* Distrib 阅读全文

posted @ 2012-02-02 09:47 kxdhm 阅读(2434) 评论(0) 推荐(0)

javascript parent.window.location
摘要:子页面:/AAA/AAA.html父页面:/BBB/BBB.html子页面中代码如下parent.window.location="CCC.html"结果:父页面跳转到:/AAA/CCC.html 阅读全文

posted @ 2012-02-01 12:27 kxdhm 阅读(646) 评论(0) 推荐(1)