Networking | Hardware | Software | Multimedia | System | Unix&Linux | MBA

Home>>Hardware>>need help running two sricpts on one page

need help running two sricpts on one page

akdrmeb
10-13-2005, 10: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, 01: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.


 

TOP

For more info

setting a minimum size
Auto Preview of Image 
Refresh with a query s
JS Validation obsolete
Javascript Pop up func
Slide show transitions
I'm a newbie...please!
how to write coding in
Advanced Debug Info 
.js file doesn't work 

News Archive

Adding Graphic To Text
re-direct form after s
pop up window controls
Clock on homepage - He
passing a param from a
Password Procection wi
document.title in same
focus onload 
Counting Wrong from Ri
Help needed on how to 

Related stories:

Accessing the CD drive from a disk in...the same drive!
Why doesn't 'total' box work!?
Time Refreshing
Problem with popup window
(please) Help with onmouseover images
Changing the onClick function call dynamically
Javascript / PHP Date Function
Calculating string width in pixels

Copyright@2004-2005 www.zzcoke.com All Right Reserved

advanced web statistics