For a lot of recursion, what does this code do?

I implemented part of this script to help me with debugging

var ZFDebugLoad = window.onload;
window.onload = function(){
   if (ZFDebugLoad) {
      ZFDebugLoad();
   }
   ZFDebugCollapsed();
};

Firebug gives me the error "break on Error too much recursion"

The code is like an endless loop for me, so I wonder why the original author introduced it. There is also no return to the function, so ZFDebugLoad will never matter ...

EDIT The real cause of this error (for any other people who followed the same tutorial as me, the reason for the error was this line

$response->setBody(preg_replace('/(<head.*>)/i', '$1' . $this->_headerOutput(), $response->getBody()));

which uses the regex template /(<head.*>)/i, this caused the script to be added to my HTML5 tag <header>, t fix it, I put a space in the template/<head(?!er).*?>/i

+3
source share
2 answers

ZFDebugLoad window.onload, .

load , , ZFDebugCollapsed.
. JavaScript . if (ZFDebugLoad) , ZFDebugLoad undefined , script window.onload. udefined, .

+2

script , .

script , . , , script, window.onload , window.onload ZFDebugLoad .

window.onload ZFDebugLoad, , , , ZFDebug, , , ...

Ad infinitum.

+2

All Articles