Tuck Design
Bookmark and Share
Screen Tool Download for free demo version of Screen Tool:
screen capturing software for Windows, Linux (static) or MacOSX.
It will let you easily capture screen,
make annotations
and send it through Skype or save it.
For more details and shop click here.


Questions/Answers regarding javascript code.


I'm trying to come up with a solution for detecting when an image,
loaded by a script, has completely loaded. The Image.onload event is
fired after the image has loaded in Firefox but in IE it doesn't work that way. How to solve this?
Here is nice solution for you. Assign to image onload event whatever function you need, and after that just call (img).imgOnLoad() - where "(img)" is your image object.

Image.prototype.imgOnLoad=function () {
    if (!document.all) return;
    if (this.complete && this.complete==true) {
        if (typeof(this.onload)=="function") this.onload();
    } else {
        if (!this.id) this.id=((Math.random()*100000)+"").replace(".","");
        setTimeout("if (document.getElementById('"+this.id+"')) document.getElementById('"+this.id+"').imgOnLoad()",50);
    }
}
You need to login to be able to post your answer.
I am using external javascript files that I can not change. It starts some setTimeout or setInterval that make errors on my page. How can I remove all setTimeouts and all setIntervals that external script starts?
You can replace default windoew.setTimeout and window.setInterval functions to remember all values these functions return and then stop them by clearTimeout or clearInterval. Here is the code for it:
var toutIDs=new Array;
var intIDs=new Array;

function newTimeout(code,interval) {
  var tmp=oldSetTimeout(code, interval);
  toutIDs[toutIDs.length]=tmp;
  return tmp;
}

function newInterval(code,interval) {
  var tmp=oldSetInterval(code, interval);
  intIDs[intIDs.length]=tmp;
  return tmp;
}

function clearAllTimeouts() {
  for (var i=0; i<toutIDs.length; i++) {
    clearTimeout(toutIDs[i]);
    delete toutIDs[i];
  }
  toutIDs.length=0;
}

function clearAllIntervals() {
  for (var i=0; i<intIDs.length; i++) {
    clearTimeout(intIDs[i]);
    delete intIDs[i];
  }
  intIDs.length=0;
}

var oldSetTimeout=window.setTimeout;
var oldSetInterval=window.setInterval;

window.setTimeout=newTimeout;
window.setInterval=newInterval;

All you need to do is put this code in script (loaded before any other script!) and if you want to clear all timeouts or interval you just call clearAllTimeouts() or clearAllIntervalss()
You need to login to be able to post your answer.
What is new?
    follow us on Twitter


    screen-capture-tools :: screen-tool

    screen-capture-tools :: screen-tool

    1stdownload