Crash IE, slow down Firefox, with this e-mail validation routine

Searching the internet I found the following e-mail validation routine:


function isValidEmailAddress( address )
{
return String(address).match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,7})+$/);
}

Feed the following (invalid) address to the routine

123456789012345678901234567890abcdefg

Result:

IE hangs, need a complete browser restart!! Maybe you need to be very very patient!
Firefox detects a slow script

I think this is pretty strange!!

Click the link below to test this 'bug':

Please crash my browser

Closing an IE popup two times while busy with Ajax request hangs IE

Closing an IE popup (twice) while a XmlHttpRequest is running, uses up all available connections.

To reproduce this:
- create a slow XmlHttpRequest (xhr). (Running about a minute or so)
- Open a popup window which executes this xhr. Close it while it's still running
- Open this same popup again. (Second request). Directly close it while the xhr is running.
- Open another popup... et voila... IE Hangs..

This problem is what I was experiencing. After hours of frustrations we found a workaround:
In the onunload of the body tag you must call the "open" method on the same XmlHttpRequest object.
The call of "open" disconnects and stops the old request. Appearently abort doesn't do this

Working code:










WARNING: This solution has only be tested with IE7!

Update 23-01-2008:

Solution for this problem with prototype is. Just put this code in an seperate javascript file. Include this file after prototype.js call iefix_runGarbageControl() in the onunload and the bug is fixed ;-)


// IE TCP/IP Connection Leak FIX, with prototype
if( Prototype.Browser.IE )
{
var iefix_xhrs = new Array();
function iefix_runGarbageControl() {
for(var i=0; i

Update 24-04-2008:
Added: place 'iefix_runGarbageControl()' in the onunload

Don’t use innerHTML, but use Prototype’s Element.update method!

Note to self: When using prototype don't use the innerHTML property.

Internet Explorer has got a (in my opinion) broken implementation for certain elements.
It is not possible to change the innerHTML content of the TR and SELECT elements.

Fortunally Prototype has fixed these problems in the Element.update method!


$("tr_id").update( "

Test

" );

Great method to_json

A very nice method to convert a Ruby array to Javascript.

print { 'key1' =>  'value1', 'key2' => [ 1,  2, 3 ] }.to_json
outputs:  { key1: 'value1', key1: [ 1, 2, 3 ] }

Prototype automatic Spinner

I found the following code on the internet. By using this code, a spinner is showed automaticly if an Ajax request is running. Very nice!

// registreer een algemene spinner
Ajax.Responders.register({
  onCreate: function() {
  if (Ajax.activeRequestCount > 0)
    Element.show('spinner');
  },
  onComplete: function() {
  if (Ajax.activeRequestCount == 0)
    Element.hide('spinner');
  }
});

Didn't know prototype had this global register method. I should take a better look at the API!