473,395 Members | 1,516 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to apply "body onload" event (javascript) to 2 images on same page

my html file has the coding following..

Expand|Select|Wrap|Line Numbers
  1. <html> 
  2.  
  3. <head> 
  4.  
  5. <script language="javascript" src="/var/www/external.js"></script> 
  6.  
  7. <script langauge="javascript"> 
  8.  
  9. function changeIt() 
  10.  
  11.  
  12. this.width  = 50; 
  13.  
  14. this.height = 50; 
  15.  
  16.  
  17. </script> 
  18.  
  19. </head> 
  20.  
  21. <body> 
  22.  
  23. <body onload="changeIt();"> 
  24.  
  25. <img src="/home/administrator/Desktop/aa.jpeg" name="image" onclick="changeeIt();">  
  26.  
  27. <img src="/home/administrator/Desktop/ppp.jpg" name="image1" onclick="changeeIt();"> 
  28.  
  29. </body> 
  30.  
  31. </html> 
  32.  
  33.  

when the page loads..

<body onload="changeIt();"> is not working..the images are shown in there original size

please somebody help
thanks in advance
Oct 12 '10 #1
2 2001
gits
5,390 Expert Mod 4TB
of course ... the function sets this.width and this.height ... what do you expect that this refers to?

in your current case this refers to the window object - what certainly is not the intention. so you would have to pass a reference to an image to the function. and since the function actually could just handle one reference you would need to call it for every image you want to resize - either sequentially or better in a loop ...

PS: besides that - what is declared in external.js?
Oct 12 '10 #2
Dormilich
8,658 Expert Mod 8TB
@gits: source thread
Oct 13 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Peter Cartwright | last post by:
Is there a functional equivalent to <body onload="function call" in the main script. Can one do something like document.body.onload=function call?
4
by: Viken Karaguesian | last post by:
Hello all, I have a question. I trying to run two Javascripts on my webpage, both of which need a <body onload> command. They are as follows: <body onload="runMe()"> <body...
2
by: cmay | last post by:
I have recently been working with RegisterStartScript in my asp.net pages. However, as you probably know it places the script at the end of the FORM tag. However, when this code executes on...
7
by: Calvin KD | last post by:
Hi everyone, Has someone out there experienced the same problem? What i wanted to do is to display a popup window (modal) upon the loading of a webpage. Here is my code sample (in html view):...
1
by: lwhitb1 | last post by:
I have been trying to load a javascript function from the body onload html tag, but I only want the function to load the first time the page is loaded: I have investigated but haven't found...
22
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the...
4
by: stevong | last post by:
It works on Konquerer though. I remember it works on IE too. I've tried window.close() too. Doesn't work on Firefox also. I've also tried to create a function. It doesnt work on Firefox also....
5
by: tuxedo | last post by:
The way the <body onload="something()"works ensures that the complete html document is loaded before something() is executed. Can the same be achieved when placing the onload call in document...
18
by: tarunkhatri | last post by:
HI can anyone help me with a function of javascript ... that calculates the sum of all colums at the very last row and also sum of all rows at the very last coloum.... It wiuld be like a 2-d array...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.