Recent Notes

Displaying keyword search results 1 - 10
Created by James on May 03, 2012 14:54:46    Last update: May 03, 2012 14:54:46
History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. For HTML4 browsers it will revert back to using the old onhashchange functionality. All major browsers are supported. This is a simple test page to get started: <html> <head> <title>Test History</title> ... Note: state url must be provided for IE to generate a unique hash. YOu can prefix the state url with '?' ('#' does not work).
Created by Dr. Xi on February 08, 2011 14:45:13    Last update: February 08, 2011 14:45:50
The ECMAScript defines these single character escape sequences: Escape Sequence Code Unit Value Name Symbol \b \u0008 backspace <BS> \t \u0009 horizontal tab <HT> \n \u000A line feed (new line) <LF> \v \u000B vertical tab <VT> \f \u000C form feed <FF> \r \u000D carriage return <CR> \" \u0022 double quote " \' \u0027 single quote ' \\ \u005C backslash \ Escape sequences can also be: \0 (backspash zero): the <NUL> character. \xdd (x followed by two hexadecimal digits): a Latin-1 character whose code unit value is the value of the hexadecimal number. \udddd (u followed by 4 hexadecimal digits): A Unicode character whose code unit value equals the value of the hexadecimal number. \ddd (backslash followed by 3 octal digits): a Latin-1 character specified as...
Created by James on July 04, 2009 16:30:40    Last update: January 11, 2011 21:21:59
If you are looking for a solution for a progress bar, I direct you to the following resources: Bare Naked App provides a simple and elegant solution based on pure CSS with two images. You control the percentage of completion through the background-position attribute of the CSS. HTML: <img src="/images/percentImage.png" alt="... CSS: img.percentImage { background: white url(/imag... Images: (percentImage.png) (percentImage_back.png) WebAppers extended the above solution with JavaScript. They also added several colored images: JQuery UI has a built-in progress bar widget. However, if you want to get to understand some of the foobar needed to get CSS to work (in general) through this example, stay with me for the rest of this note. Initially I was thinking, a progress bar should be easy: just make...
Created by James on October 06, 2010 20:54:39    Last update: October 06, 2010 20:55:00
When a JavaScript call is taking too much time, Firefox pops up this message: Of course the solution is to speed up your script. But suppose it really needs to exceed the preset timeout, you can delay the popup by following these steps: Enter about:config in the address bar Ignore the warning and proceed Enter dom.max_chrom in the filter input Change the value of dom.max_chrome_script_run_time to a bigger value (default is 20). For IE, there's a similar dialog with this message: "A script on this page is causing Internet Explorer to run slowly". But rather than counting elapsed time, IE counts the number of statements executed , which is controlled by the registry key HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Styles . You need to create a DWORD value named...
Created by James on June 30, 2010 19:04:45    Last update: July 03, 2010 21:24:33
Technically, file upload cannot be handled by Ajax, because XMLHttpRequest (XHR) does not handle file inputs. All techniques not using Flash rely on an invisible iframe as the upload form submit target. JavaScript then grabs the response content from the iframe and present it, giving the same illusion as Ajax. webtoolkit AIM The technique by webtoolkit is very simple. It involves 3 simple steps: include the AIM script, implement the start/finish JavaScript functions, and add an onsubmit handler to the normal file upload form. The hooked up form looks like: <head> <script type="text/javascript" src="webt... The AIM script is also quite simple: /** * * AJAX IFRAME METHOD (AIM) * http... The above code only supports HTML responses. In order to support JSON responses, the above...
Created by James on June 30, 2010 20:14:28    Last update: July 03, 2010 18:41:12
The HTML page <!DOCTYPE html> <html> <head> <title>jQu... Client Side Code // called before upload submit function sta... Server Side Code Using Apache Commons FileUpload as example. Upload code (responds to fileUpload.do ): final HttpSession session = httpServletRequest... Progress code (responds to uploadProgress.do ): HttpSession session = httpServletRequest.getSe...
Created by James on May 23, 2009 19:46:01    Last update: May 23, 2009 19:49:46
This topic comes up once in a while: I need to generate a random string in JavaScript to get around browser (IE) cacheing. Method 1 (not really random, but a new value every millisecond): function randomString() { return '' + n... Method 2 (generate a random alpha-numerical string): function randomString(length) { var chars =...
Created by James on May 03, 2009 20:25:10    Last update: May 03, 2009 20:25:10
Some interesting information about getting the value of tabindex with JavaScript: http://www.fluidproject.org/pipermail/fluid-work/2007-December/001129.html Especially, IE returns 0 when tabindex is not set, making it indistinguishable from where tabindex is set to 0.
Created by Dr. Xi on January 29, 2009 21:33:44    Last update: January 30, 2009 17:43:33
You can use applet , object , or embed tags to embed an applet in your HTML page. However, The applet tag is interpreted by both IE and Mozilla family of browsers. The applet tag won't automatically download a JRE if the Java Plug-in isn't already installed. The object tag works only for IE The embed tag works only for Mozilla family of browsers, i.e., Firefox. Use applet tag: <applet code="MyApplet.class" width="200" ... Use object tag: <!-- latest JRE --> <OBJECT classid="clsid:... Use embed tag: <!-- highest JRE that supports MIME type ... Mixed object and embed tag: <object classid="clsid:8AD9C840-044E-11D1-B3E9... You need to use a different name for the Mozilla embed tag and use that name to refer to the applet...
Created by Dr. Xi on November 15, 2007 04:40:44    Last update: November 15, 2007 04:40:44
Here's some simple Ajax code. The Ajax response is delivered as XML with attributes and an array of data payloads contained in CDATA sections: <?xml version="1.0" encoding="utf-8"?> <ajax-re... And the JavaScript that does the Ajax magic: // ajax.js function ajaxGet(url, ajaxCallback) ... And the HTML test code: <html> <head> <script language="JavaScript"...