There are two window.onload statements in CS (template.php and page.tpl.php) which breaks Drupal 4.7 JS. The CS JS should be synced to 4.7JS

Comments

traemccombs’s picture

Title: onload problems » [DRUPAL-4-7] onload problems
Assigned: Unassigned » traemccombs

Filing this as a bug for the 4.7 port.

Chx, if you have a fix for this, which it seems you do, can you please post a patch?

Thanks,
Trae

chx’s picture

I do not have, I merely killed the JS as the site we were working on did not require the fancy filter tips.

douggreen’s picture

sweetooth’s picture

Drupal uses the onload event to handle a lot of JS stuff, but sometimes you want to also use onload. Directly using window.onload will cause any previously set events to be cancelled basically. Simon Willison came up with a nice method for adding onload events into a queue basically, and this is the method that I use to call functions in themes rather than using window.onload etc. The comment is mine, the code was written by Simon Willison and links to his article describing the issue.

So, the solution. Include the below javascript and then when you want to add events to the onload use
addLoadEvent( myFunction() );
instead of window.onload = myFunction();
or other methods.

As far as I know drupal doesn't provide any methods to append to the onload event, but of course I could be wrong.

/* Add onload events through a handler
   Author: Simon Willison
   Source: http://simon.incutio.com/archive/2004/05/26/addLoadEvent

   addLoadEvent(nameOfSomeFunctionToRunOnPageLoad);
   addLoadEvent(function() {
     // more code to run on page load
   });
*/

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
douggreen’s picture

Status: Active » Closed (won't fix)

The CIvicSpace theme was never fully upgraded to 4.7. Given that we're now working on 6.x, I'm marking this issue as won't fix.