...

View Full Version : need help running two sricpts on one page



akdrmeb
10-13-2005, 11:26 PM
I know this is easy, everything I have read on the topic makes sense yet I have struggled for 2 days now with no progess.

Heres the problem: I am running two javascripts on the same page and they are interfering with eachother b/c of the <body= onload handler... what do i need to do these so both will run without interference??

Heres how the page looks from step 1.
<html>
<head>
<script type='text/javascript'>
window.onload=function () {
for(var i=0; imgEle=document.getElementsByTagName('img')[i];i++)
if (imgEle.height > 500){ imgEle.width = Math.round(((500)/imgEle.height)*imgEle.width); imgEle.height = (500); }
}
</script>
</head>

<body onload="document.getElementsByTagName('input')[0].focus();">
</body>
</html>

Thanks in advance.

rlemon
10-14-2005, 02:44 AM
<html>
<head>
<script type='text/javascript'>
function init() {
for(var i=0; imgEle=document.getElementsByTagName('img')[i];i++)
if (imgEle.height > 500){ imgEle.width = Math.round(((500)/imgEle.height)*imgEle.width); imgEle.height = (500); }

document.getElementsByTagName('input')[0].focus();
}
</script>
</head>

<body onload="init()">
</body>
</html>



however i think there is more wrong with your code. the for loop looks a little off.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum