473,395 Members | 1,379 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.

IMG Javascript question

So just started playing with Javascript, and my first run at making three
step buttons came out just fine. But I do have a general question.

In my book's example in the HTML script the IMG tags have the button's
settnigs for Width, Height, Border (0), and even grant each button an "id".

The "id" label is not used in the Javascript, so I was wondering if it and
the other items listed above MUST be in the HTML code, or does the book have
it in there just to be all proper like?

Many thanks
Jun 30 '08 #1
1 1208
SAM
Daniel Kaplan a écrit :
So just started playing with Javascript, and my first run at making three
step buttons came out just fine. But I do have a general question.

In my book's example in the HTML script the IMG tags have the button's
settnigs for Width, Height, Border (0), and even grant each button an "id".

The "id" label is not used in the Javascript, so I was wondering if it and
the other items listed above MUST be in the HTML code, or does the book have
it in there just to be all proper like?
certainly in next pages of your book they will learn to you how to use
this ID in JS.

For the moment, notice that you can have only one ID of same name in a page
(2 or more identical ids is forbidden - the JS will have to be abble to
find the element (object?) by its ID, with several clones it will
retreive only the 1rst of them)


Of course, if these IDs are not used you can delette them
(be sure they are not used by CSS)
(take care your exercice will be used in next ones and probably there
the IDs will get sens)


width, height, border can be fixed by CSS.

Get used to write all your code (even in HTML) in lowercase
(Height -height - onMouseOver -onmouseover)
If the HTML is not case sensitive, the JS it is.

If you'll do :

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function hello() { alert('hello');}
  3. function init() {
  4. document.images[0].onClick = hello;
  5. }
  6. window.onload = init;
  7. </script>
that will not work because in JS it is : onclick


Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function hello() { alert('hello');}
  3. function init() {
  4. if(document.images && document.images.length>0)
  5. {
  6. document.images[0].omouseover = hello;
  7. }
  8. }
  9. window.onload = init;
  10. </script>
--
sm
Jun 30 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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: 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.