Posts Tagged ‘prototype’

Stop A Page From Loading

Friday, July 4th, 2008

I've recently put together a page that included over 550 thumbnails that were set to load dynamically. They were grouped together to be viewed throughout several "pages". Originally, if you went to the second page without waiting for the first to finish loading, you'd be unimpressed with the presentation. The second page would begin to load only after the first was finished and so on. I needed to come up with a way to stop the thumbs from loading when you went to the next page and here's what I came up with. It works with Firefox, Safari, and the troublemaker...Internet Explorer.

Using Mootools:

function stopLoad()
{
   $try(
      function(){window.stop()},
      function(){document.execCommand('Stop')}
   )
}

Using Prototype:

function stopLoad()
{
   Try.these(
      function(){window.stop()},
      function(){document.execCommand('Stop')}
   )
}