Forum Moderators: open
I would guess that the above onload does nothing, but I'd be careful before removing it. Depending on how the system is built, perhaps on some pages there is an onload event needed. The system might be placing either the real action on pages that require it, or the void() action if not. So if you remove the onload completely in the template, perhaps that would break the onload on certain specific pages.
Personally, I'd leave it in unless you're really sure - 17 bytes per page won't break the bandwidth budget, but a broken page on the site could cause big problems.
The void operator is used in either of the following ways:1. void (expression)
2. void expressionThe void operator specifies an expression to be evaluated without returning a value. expression is a JavaScript expression to evaluate. The parentheses surrounding the expression are optional, but it is good style to use them.
Implemented in
JavaScript 1.1
ECMA version
ECMA-262
You can use the void operator to specify an expression as a hypertext link. The expression is evaluated but is not loaded in place of the current document.
The following code creates a hypertext link that does nothing when the user clicks it. When the user clicks the link, void(0) evaluates to 0, but that has no effect in JavaScript.
<A HREF="javascript:void(0)">Click here to do nothing</A>
The following code creates a hypertext link that submits a form when the user clicks it.
<A HREF="javascript:void(document.form.submit())">Click here to submit</A>
Perhaps it is in the onload event to quash any error messages that might otherwise pop up? Just musing ...
I'm not savvy on the sequence of processing when a page is loaded, so this is a shot in the dark, but here's the general idea anyway: An "onload" handler may be installed in several ways. One is the onload attribute to the body tag, our example. Another is a statement "window.onload=func;" in a JavaScript file. There are probably others.
Now if both of those (or others) are present when a page is loaded, then one of them must take precedence. If(!) the tag attribute takes precedence, then our example would prevent a JavaScript injected onload function to take hold. The site may have such JavaScript in place, which is normally desired, but disabled like this on a few pages.
As I said, this is the most reasonable speculation I could come up with, but it may be worth checking the specifications to verify or disprove it.
Would a "content-management system" be GoLive? That is what we are using.
I could always just remove the code as I work on individual pages, and test them, but even with that strategy, it may not be worth thoroughly testing all functionality of each page just to see if it was needed at all.
Just something that was bugging me. Thanks again...