473,396 Members | 2,030 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,396 software developers and data experts.

rollover problem

Can someone please tell me what the heck is wrong with my code here on line
59 and 60. i get an error that says object expected and I have NO
understanding why. There must be something im overlooking and its really
irritating because i know how simple this should.
================================================== ==========================
======
<HTML>
<HEAD>
<TITLE>MENU</TITLE>
<SPRIPT LANGUAGE = "JavaScript">
<!--

if (document.images) {

img1on = new Image();
img1on.src = "buttons/button_2_up.gif";

img2on = new Image();
img2on.src = "buttons/button_4_up.gif";

img3on = new Image();
img3on.src = "buttons/button_6_up.gif";

img4on = new Image();
img4on.src = "buttons/button_8_up.gif";
img1off = new Image();
img1off.src = "buttons/button_2_down.gif";

img2off = new Image();
img2off.src = "buttons/button_4_down.gif";

img3off = new Image();
img3off.src = "buttons/button_6_down.gif";

img4off = new Image();
img4off.src = "buttons/button_8_down.gif";
}

function imgOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "on.src");
}
}

function imgOff(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "off.src");
}
}
//-->

</SCRIPT>

</HEAD>
<BODY>

<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="135">

<TR><IMG SRC="buttons\logo.gif" width="135" heigth="117" border="0"></TR>
<TR><IMG SRC="buttons\menu.gif" border="0"></TR>
<TR><IMG SRC="buttons\button_1_down.gif" border="0"></TR>

<TR><A href = "products.html" target="main"
onMouseOver = "imgOn('img1')" // this is the
line with the error!!!
onMouseOut = "imgOff('img1')"> // this one
too
<IMG NAME = "img1" border=0 height=27 width=128
src="buttons\button_2_down.gif"></A></TR>

<TR><IMG SRC="buttons\button_3_down.gif" border="0"></TR>
<TR><IMG SRC="buttons\button_4_down.gif" border="0"></TR>
<TR><IMG SRC="buttons\button_5_down.gif" border="0"></TR>
<TR><IMG SRC="buttons\button_6_down.gif" border="0"></TR>
<TR><IMG SRC="buttons\button_7_down.gif" border="0"></TR>
<TR><IMG SRC="buttons\button_8_down.gif" border="0"></TR>
<TR><IMG SRC="buttons\button_9_down.gif" border="0"></TR>
<TR><IMG SRC="buttons\button_10_down.gif" border="0"></TR>
</BODY>
</TABLE>
</HTML>
Jul 20 '05 #1
1 1547
"Paul Weikel" <we*****@earthlink.net> writes:
Can someone please tell me what the heck is wrong with my code here on line
59 and 60. i get an error that says object expected and I have NO
understanding why. There must be something im overlooking and its really
irritating because i know how simple this should.
I'll just give it the full treatment :)

Remember a DOCTYPE to set the browser into standards mode. <HTML>
<HEAD>
<TITLE>MENU</TITLE>
<SPRIPT LANGUAGE = "JavaScript"> ^
This P shoud be a C.
Also, the language attribute is depreacted and the type attribute is
required. Change this to
<script type="text/javascript">
<!--
HTML comments are not necessary in Javascript code.
if (document.images) {
Which currently used browsers don't have document.images?
Why do you test for it, if you don't use it? (even though you should
use it!)
function imgOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + "on.src");
Bad code. It assumes the image is available as a property of the
document element. If you test for document.images, you might as well
use it.

You use eval to access a variable/object property. That is never
necessary, and should be avoided.

Change to:
document.images[imgName].src = window[imgName+"on"].src;

(Instead of a lot of global variables, you could have made just
one pointing to an object, and then stored the Image elements in it.
document[imgName].src = eval(imgName + "off.src");
As above.
//--> As for opening comments.
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="135">
Consider using CSS for controlling display. It is more powerful
than HTML attributes.
<TR><A href = "products.html" target="main"
onMouseOver = "imgOn('img1')" // this is the
line with the error!!!
onMouseOut = "imgOff('img1')"> // this one
too


Both errors probablt come from the "spript" tag. The functions are
simply not defined.

To find errors like this, you can use an HTML validator like
<URL:http://validator.w3.org/>. (It requires adding a DOCTYPE
declaration, but you should do that anyway).

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

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

Similar topics

5
by: Brian Angliss | last post by:
I'm relatively new to scripting in JavaScript, so I'm not too surprised I'm having difficulty scripting up an animation effect for my personal site. What I'm trying to do is the following: When...
1
by: nick | last post by:
I have the following code: <style> #item1 { DISPLAY: block; BACKGROUND: url(ProjMenuImgs/ProjBtn.gif) no-repeat 0px 0px; WIDTH: 87px; HEIGHT: 94px; } #item1:hover { background-position: 0...
4
by: Leythos | last post by:
I've got several sites that I used DreamWeaver MX to add RollOver buttons to the pages, it also adds some javascript that pre-loads the images and does the mouse_over and such. In FireFox 1.0.1...
5
by: Bribro | last post by:
I have an horizontal menu with a dreamweaver-generated rollover effect. Images are png and their transparency is handled by pngfix.js In IE, applied the pngfix, the rollover doesn't work at all....
47
by: Lauren Quantrell | last post by:
I have constructed the following code that simulates the common rollover effect when moving the mouse over a label (this example makes the label bold.) I'm wondering if anyone has come up with...
6
by: AJBopp | last post by:
I'm wrestling with CSS variations between Firefox and IE. I'm trying to create rollover buttons in a menu frame. It is working perfectly in Firefox but in IE only the first button is properly...
3
by: Rob R. Ainscough | last post by:
Just curious why a VERY commonly used affect of rollover was NOT implemented in .NET 2.0 for web controls? Does anyone have a link to VB code that will show me how to build my own UserControl...
1
by: mckrooks101 | last post by:
My problem is that I have a javascript cycling banner at the top of my page and navigation buttons about 20 pixel underneath that both have external js files but the banner doesn't work when I...
3
by: Oriane | last post by:
Hi there, I would like to handle a "rollover" <asp:Buttonin the code behind with C# with this kind of code: Button btn = Page.FindControl("Button" + numWidget) as Button; btn.Attributes =...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.