I can't add an onload event to the body tag of my template without breaking the admin pages. What's the workaround? I keep reading about the addLoadEvent() function but I don't understand how to integrate it into my php template.
I can't add an onload event to the body tag of my template without breaking the admin pages. What's the workaround? I keep reading about the addLoadEvent() function but I don't understand how to integrate it into my php template.
Comments
Comment #1
criznach commentedCalling onload functions in this way breaks compatibility with certain scripts that depend upon the page being loaded first. For example, Project 7's Pop Menu Magic's init function must be in the body/onload attribute to work properly.
Comment #2
bpedigo commentedSo how do I do it the right way? I can't figure it out. :(
Comment #3
filiptc commentedThere are TONS of us who are having the same issue. Please, is there a workaround to call our own onload functions? If not please fix the issue.
Regards,
Phil
Comment #4
criznach commentedI was finally able to make this work.
I done it in this example, but you may choose to escape the script block with a comment or CDATA block as needed for validation purposes. There is a lengthy discussion of this topic somewhere... I can't remember where.
Place the following code at the end of your page head...
Then, place this immediately after the body tag opens.
Comment #5
criznach commentedHere's the article on correct script escaping in XHTML.
http://en.wikibooks.org/wiki/Programming:Complete_PHP/Escaping_from_HTML...
You'll also want to close that first script block... :)