javascript
1 2009-1-29 javascript links
- http://javascript.crockford.com/ Douglas Crockford's javascript site
- http://jslint.com/ The JavaScript Verifier
- http://developer.yahoo.com/yui The Yahoo! User Interface Library (YUI)
- http://code.google.com/ GWT, google ajax API etc.
- http://www.hunlock.com/blogs/Functional_Javascript Javscript Reference Series on Functional Javascript
- http://jsonformatter.curiousconcept.com/ JSON Formatter
2 2009-4-19 parse URL to get parameters
one source http://www.webdevelopmentcentral.net/2006/06/parsing-url-variables-with-javascript.html:
var searchString = document.location.search;
// strip off the leading '?'
searchString = searchString.substring(1);
var nvPairs = searchString.split("&");
for (i = 0; i < nvPairs.length; i++)
{
var nvPair = nvPairs[i].split("=");
var name = nvPair[0];
var value = nvPair[1];
}
http://www.netlobo.com/url_query_string_javascript.html is regex-based:
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
3 2009-7-3 evil eval
Something like eval("("+response+")") is very tantalizing when you have a json string and want to convert it into js data structure right away.
However, if the response happens to turn into something non js, like an error message which contains some js keywords or some other wacky stuff, it'll mess up the syntax of all of the code. You'll get strange errors like
missing ) parenthetical
while your code is solid js.