Javascript中的var_dump函数实现代码


发现了一个非常好的JavaScript调试方法,目前看到的是可以打印Object/Array/Function/String四种类型,使用方法和PHP中的var_dump()一样,只要直接dump(变量名)即可。

复制代码 代码如下:

dump(value, [showTypes])
@ param value (Any) value to dump
@ param [showTypes] (Boolean) optional to display each key/value's type
@ return (Void) returns nothing


The Dump method is based on one of the tags available in Coldfusion ( <cfdump>) providing the ability to display simple and complex variables in a user friendly way that is perfect for debugging/inspecting data. There is no way to do this with javascript and often I had wanted a method to do this. This method will do just that allowing for an infinite amount of data nesting complete with color coding for different data types, the ability to show/hide the data's type (String/Number/Boolean/Object/Array/Function), expandable and collapsible tables/keys and cross browser support.

Click on the buttons bellow to see some examples in action, toggle the Show Data Types box to see javascript data typing in action (not possible in Coldfusion).

Browser Support
Internet Explorer 6, Internet Explorer 7, Firefox 1.5, Opera 8, Safari 1.2 (Mac), Firefox (Mac) - all tested, should also work in most other browsers

Dump Examples
官方网址
http://www.netgrow.com.au/files/javascript_dump.cfm
相关文件
http://www.netgrow.com.au/assets/files/dump/dump.zip

以防上面的地址下载不了,phpStudy本地下载地址
http://www.phpstudy.net/jiaoben/20804.html



相关阅读:
php+oracle 分页类
PHP学习入门的一些基础知识(菜鸟必看)
Windows Server 2008中几个实用命令下
Linux Mint 9 RC版使用体验
Javascript教程:获取当前地址栏url
熟悉Linux内核安全入侵侦察系统
Wayland:Linux的新X Server
ASP网页模板的应用: 让程序和界面分离,让ASP脚本更清晰,更换界面更容易
Javascript 网页水印(非图片水印)实现代码
网页制作教程:在IE7中的网页文本重影问题
javascript[js]获取url参数的代码
php内置函数intval()利用不当的安全漏洞分析
用PHP为SHOPEX增加日志功能代码
整理一些JavaScript的IE和火狐的兼容性注意事项
快速导航

Copyright © 2016 phpStudy |