Access parent window from modalDialog
When you call showModalDialog() you need to pass “self”, without the quotes, as the second argument.
You can then access the parent(opener) with:
var opener = window.dialogArguments;
You can then access any function declared in parent window with:
opener.myFunction();
Rules for Speeding Up Your Web Site
Yahoo Developer Network posted a nice set of rules to speed up your website. The excerpt is as follows:
- Make Fewer HTTP Requests
- Use a Content Delivery Network
- Add an Expires Header
- Gzip Components
- Put Stylesheets at the Top
- Put Scripts at the Bottom
- Avoid CSS Expressions
- Make JavaScript and CSS External
- Reduce DNS Lookups
- Minify JavaScript
- Avoid Redirects
- Remove Duplicate Scripts
- Configure ETags
You can read the full article here.
Validate e-mail address with regular expression
/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
All regular expressions start and end with forward slashes to differentiate them from ordinary string expressions. Most regular expressions start matches at the first character ^ and end at the last $.
Now we try to match the mailbox name which can include periods and dashes \w+ states one or more alphanumeric must be at the start of the name. ([\.-]?\w+)* allows periods or dashes to be included in the mailbox name with the trailing \w+ ensuring that those characters can not finish the name. The @ is the mandatory separator.
The domain name can have several .xx or .xyz suffixes such as .com.uk. Once again \w+ ensures that domain starts with an alphanumeric and ([\.-]?\w+)* allows for the dashes and periods. Finally (\.\w{2,3})+ ensures that there is at least one suffix of between 2 and 3 characters preceded by a period.
Note: This is not a completely foolproof validation as it does not account for new domain names of 4 or more characters. Also not all two and three letter combinations are legitimate domains!
Trim a string with all types of spaces
var a = “151 “;
a = a.replace(/^\s+|\s+$/, “”);
//a is now “151″ .
Note:
\s : Matches a single white space character, including space, tab, form feed, line feed.
Equivalent to [ \f\n\r\t\v\u00A0\u2028\u2029].
\S: Matches a single character other than white space.
Equivalent to [^ \f\n\r\t\v\u00A0\u2028\u2029].
