Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.onload problem

Status
Not open for further replies.

okiiyama

IS-IT--Management
Joined
Jan 3, 2003
Messages
269
Location
US
The storyline here is a little messy, so I'll suppress the details. Anyways, I've been working on a hack-job that recreates a "left nav table" through javascript. Surprisingly it works in both IE and mozilla. However, trouble has erupted because I'm using body.onload to run the function(s), and there is another piece of code in a place I have no control over that is also calling window.onload. So, my onload function is replacing the other onload function, and the other onload function doesn't run. I need it to run, so is there something I could do to have them both run?

Thanks.
 
Execute both actions using a single javascript.
Code:
<script type="javascript" event="onload">
<!--//
[i]functionOne()[/i]; // replace with onload function #1
[i]functionTwo()[/i]; // replace with onload function #2
//-->
</script>

M. Brooks
 
This works for me:

Code:
/* Onload code */
	if (typeof window.onload == 'function') {
		var _tempOnload = window.onload;
		window.onload = function() {
			_tempOnload();
			// yourFuncCallHere();
		}
	} else {
		window.onload = function () {
			// yourFuncCallHere();
		};
	}

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks, I was able to find the other onload function and all it was doing was setting an iframe src, so I included that piece of code with mine and it works good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top