Document specifier "object" not recognized.

In the following script, the document specifier and its argument,
    document[imgName].src give browser errors as object not identiefed.

Is this code correct ?

please write,

James Avakian, webmaster@productlist.com
Optical Automation, Inc.
////////////////////

<script language="JavaScript">
<!--
// variables for testing browser version for compatibility
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
bCodeName = navigator.appCodeName;

// if Netscape 3.0 or Above or Microsoft IE 4.0
if (bVer >=4 && bCodeName == "Mozilla") ver = "n3" ;
else if(bName == "Netscape" && bVer >= 3) ver = "n3";
else ver = "xx";

// menu assignments for mouse movements
if (ver == "n3") {

submenu18on = new Image(165, 25);
submenu18on.src = "fob_b.gif";
submenu18off = new Image(165, 25);
submenu18off.src = "fob.gif";

}

// function to use when mouse is over graphic
function imgActive(imgName) {
    if (ver == "n3"){
    document[imgName].src = eval(imgName + "on.src");
    }
}

// function to use when mouse leaves graphic
function imgInactive(imgName) {
    if (ver == "n3") {
    document[imgName].src = eval(imgName + "off.src");
    }
}

// -->
</script>

<div align="left">



<a href="form.htm" onmouseover="imgActive('submenu15')" onmouseout="imgInactive('submenu15')"><img src="fob.gif" alt="Send More Info" border="0" width="165" height="25" name="submenu15"></a>


opticalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tecbuilderCommented:
There are a few things that need to be changed to make this work.  First use the name property of the img tag and assign it imgName, eg. <IMG NAME="imgName" ...>.  Next you need to modify your functions a bit.  The necessary code for your anchor and image and the functions is below.

Your anchor would then looke like:
<a href="form.htm" onmouseover="imgActive('submenu15')" onmouseout="imgInactive('submenu15')"><img name="imgName" src="fob.gif" alt="Send More Info" border="0" width="165" height="25" name="submenu15"></a>

The functions would then look like this:

function imgActive(changeImg) {
  if (ver == "n3"){
    document.imgName.src = eval(changeImg + "on.src");
  }
}

function imgInactive(changeImg) {
  if (ver == "n3"){
    document.imgName.src = eval(changeImg + "off.src");
  }
}
0
opticalAuthor Commented:
After taking your suggestion, I still get errors, although it worked brieftly once. Why ?  Please oversee this code.
//////////////////////////////////////////////////////////////
<script language="JavaScript">
// variables for testing browser version for compatibility
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
bCodeName = navigator.appCodeName;

// if Netscape 3.0 or Above or Microsoft IE 4.0
if (bVer >=4 && bCodeName == "Mozilla") ver = "n3" ;
      else if(bName == "Netscape" && bVer >= 3) ver = "n3";
            else ver = "xx";

// function to use when mouse is over graphic
function imgActive(changeImg) {
if (ver == "n3"){
    document.imgName.src = eval(changeImg + "on.src");
} }
function imgInactive(changeImg) {
    if (ver == "n3"){ document.imgName.src = eval(changeImg + "off.src");
} }

// menu assignments for mouse movements
if (ver == "n3") {
      menu1on = new Image(113, 27);
      menu1on.src = "title_software_c.gif";
      menu1off = new Image(113, 27);
      menu1off.src = "title_software.gif";
}
</script>


<body bgcolor="#FFFFFF">
<div align="center"><center>


  <tr>
    <td align="center" width="126" height="26"><a href="signin_a.html" target="center"
    onmouseover="imgActive('menu1')" onmouseout="imgInactive('menu1')"><img name="imgName"
    src="title_software.gif" width="113" height="27" alt="ProductList Software!" border="0"
    align="middle"></a> </td>
  </tr>

</body>
0
tecbuilderCommented:
I am a little confused.  You said it worked, but now it doesn't.  This leads me to believe that it isn't the code I posted, but something else.  I took your code you posted above and used it without any problems.  Because you are using tables, check to make sure that you have all the opening and closing tags necessary and in the right order.  I have run into many problems because I was missing a </td> or had a </tr> before a </td>.

Without seeing the page I can't help much more than this.  All I can say is the code I gave is good and can you post the URL or the entire page here?  I really believe it is something other than what I gave you.
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

opticalAuthor Commented:
The code is online at www.productlist.com as www.productlist.com/index_links.htm as a full page...PLease inspect for additional errors.
0
tecbuilderCommented:
Found 2 problems.  You are missing a </tr> tag.  It is needed for the menu3 row.  The second problem is that you have NAME used twice within the image tag.  Remove the NAME="menux" and everthing should work ok.
0
tecbuilderCommented:
A 2 other things, you have a </a> tag just after the <td> tag for menu6 and on line 66 you have an extra }.

I should also have added that all of the <img> tags that have NAME="menux" must be removed, where x=1-8  I didn't really make it that clear in the answer.
0
opticalAuthor Commented:
I have put this page on www.productlist.com/index_links.htm
The buttons operate, but only the first one is colored when the others are without JavaScript.  

I made duplicate functions statements bracket and anchor groupings, as per all of your talent this code should operate.

In Internet Explorer v4.01, error 'object expired' appears several times and also the top and last hrefs are not functional.

In Netscape v4.04, errorimgActive and imgInactive not defined.

please have another experts look at the following code since I would like to use it in several different sites, this is my living.  I do appreciate your help and all your service..

Sincerely, James Avakian, opticalcomm@productlist.com

/////////////////////////////////////////////////
<html>

<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta NAME="GENERATOR" CONTENT="Microsoft FrontPage 3.0">
<title>Index Links</title>
<script language="JavaScript">

<!-- variables for testing browser version for compatibility -->
bName = navigator.appName;
bVer = parseInt(navigator.appVersion);
bCodeName = navigator.appCodeName;

<!-- if Netscape 3.0 or Above or Microsoft IE 4.0            -->
if (bVer >=4 && bCodeName == "Mozilla") ver = "n3" ;
      else if(bName == "Netscape" && bVer >= 3) ver = "n3";
            else ver = "xx";


<!-- menu assignments for mouse movements            -->
if (ver == "n3") {
      menu1on = new Image(113, 27);
      menu1on.src = "title_software_c.gif";
      menu1off = new Image(113, 27);
      menu1off.src = "title_software.gif";      
      
      menu2on = new Image(113, 27);
      menu2on.src = "title_siet_contents_c.gif";
      menu2off = new Image(113, 27);
      menu2off.src = "title_site_contents.gif";      
      
      menu3on = new Image(113, 27);
      menu3on.src = "title_site_general_c.gif";
      menu3off = new Image(113, 27);
      menu3off.src = "title_site_general.gif";      
      
      menu4on = new Image(113, 27);
      menu4on.src = "title_tech_focus_c.gif";
      menu4off = new Image(113, 27);
      menu4off.src = "title_tech_focus.gif";      
      
      menu5on = new Image(113, 27);
      menu5on.src = "title_newtons_web_c.gif";
      menu5off = new Image(113, 27);
      menu5off.src = "title_newtons_web.gif";      
      
      menu6on = new Image(113, 27);
      menu6on.src = "title_news_c.gif";
      menu6off = new Image(113, 27);
      menu6off.src = "title_news.gif";      
      
      menu7on = new Image(113, 27);
      menu7on.src = "title_sample_c.gif";
      menu7off = new Image(113, 27);
      menu7off.src = "title_sample.gif";      
      
      menu8on = new Image(113, 27);
      menu8on.src = "title_search_c.gif";
      menu8off = new Image(113, 27);
      menu8off.src = "title_search.gif";      
      }

</script>
</head>

<body BGCOLOR="#FFFFFF">

<p align="center">&nbsp; </p>
<div align="center"><center>

<table BORDER="0" CELLPADDING="0" WIDTH="125" HEIGHT="302">
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="117"><a HREF="signin_a.html" target="center"><img
    SRC="shopper_lady_mini.gif" ALT="See The ProductList Newtork®" BORDER="0" HEIGHT="108"
    WIDTH="120"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="signin_a.htm" target="center"
    onmouseover="imgActive('menu1')" onmouseout="imgInactive('menu1')"><img
    SRC="title_software.gif" NAME="imgName" ALT="ProductList Software !" BORDER="0"
    HEIGHT="25" WIDTH="113" ALIGN="CENTER"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="toc_index.htm" target="center"
    onmouseover="imgActive('menu2')" onmouseout="imgInactive('menu2')"><img
    SRC="title_site_contents.gif" NAME="imgName" ALT="Table of Contents" BORDER="0"
    HEIGHT="25" WIDTH="113" ALIGN="CENTER"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="g_interest.htm" target="center"
    onmouseover="imgActive('menu3')" onmouseout="imgInactive('menu3')"><img
    SRC="title_site_general.gif" NAME="imgName" ALT="Articles Of Interest" BORDER="0"
    HEIGHT="25" WIDTH="113" ALIGN="CENTER"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="tech_focus.html" target="center"
    onmouseover="imgActive('menu4')" onmouseout="imgInactive('menu4')"><img
    SRC="title_tech_focus.gif" NAME="imgName" ALT="Tech Focus Articles Of Interest" BORDER="0"
    HEIGHT="25" WIDTH="113" ALIGN="CENTER"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="newtons_web.html" target="_top"
    onmouseover="imgActive('menu5')" onmouseout="imgInactive('menu5')"><img
    SRC="title_newtons_web.gif" NAME="imgName" ALT="Newton's Web!" BORDER="0" HEIGHT="25"
    WIDTH="113" ALIGN="CENTER"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="news0.htm" target="center"
    onmouseover="imgActive('menu6')" onmouseout="imgInactive('menu6')"><img
    SRC="title_news.gif" NAME="imgName" ALT="News Events" BORDER="0" HEIGHT="25" WIDTH="113"
    ALIGN="CENTER"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="site_develop_a.html" target="center"
    onmouseover="imgActive('menu7')" onmouseout="imgInactive('menu7')"><img
    SRC="title_sample.gif" NAME="imgName" ALT="Site Descriptions and Samples" BORDER="0"
    HEIGHT="25" WIDTH="113" ALIGN="CENTER"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="n_search.htm" target="center"
    onmouseover="imgActive('menu8')" onmouseout="imgInactive('menu8')"><img
    SRC="title_web_search.gif" NAME="imgName" ALT="Internet Search" BORDER="0" HEIGHT="25"
    WIDTH="113" ALIGN="CENTER"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="29"></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="29"><a HREF="audio_on.html" target="center"><img
    SRC="speaker.gif" ALT="Speakers / Sound On ?" BORDER="0" HEIGHT="31" WIDTH="22"
    ALIGN="CENTER"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="29"><a HREF="index_specials.htm" target="center"><img
    SRC="special.gif" ALT="special" BORDER="1" HEIGHT="16" WIDTH="65" ALIGN="CENTER"></a></td>
  </tr>
  <tr>
    <td ALIGN="CENTER" WIDTH="126" HEIGHT="29"><blockquote>
      <a HREF="toc_specials.htm#bottom" target="center"><p align="center"><img SRC="bullet2.gif"
      ALT="Daily Essentials . . ." BORDER="0" HEIGHT="10" WIDTH="7"></a> </p>
    </blockquote>
    </td>
  </tr>
</table>
</center></div>

<p>&nbsp; </p>
</body>
</html>

0
tecbuilderCommented:
>>I made duplicate functions statements bracket and anchor groupings, as per all of your talent this code should operate.<<
It would, but you keep adding another error for every 2 that you are fixing.

>>In Internet Explorer v4.01, error 'object expired' appears several times and also the top and last hrefs are not functional. <<

>>In Netscape v4.04, errorimgActive and imgInactive not defined.
Your are receiving these errors because you deleted the functions.  I don't believe I told you to do that.

>>Please have another experts look at the following code since I would like to use it in several different sites, this is my living. I do appreciate your help and all your service.<<
All I can say, is that from your original question I have answered it completly.  It is also frustrating for me as well.

Put the functions back into the your code and see if everything works.  If it does, comment back here.  Also, he is a very good way to test for browser compatibility.  Put these 2 scripts above your existing script.

<script>
// This will initialize the script.
  ver = "xx"
</script>

<script language="javascript1.1">
// Only those browsers that are capabable of doing what you want
// will set come inside this script.
  ver = "n3"
</script>

I sent you a corrected file that works the way it should for Netscape and MSIE 3.x.  I don't have MSIE 4.x.  I said MSIE 3.x, because nothing should happen if the browser is MSIE 3.x and it doesn't.

0
opticalAuthor Commented:
Thank you for your help, your code and its enhancement are just right.  The code still does not work because the host has written a NetObjects Style sheet to not allow JavaScript for Internet Explorer and only allow when using Netscape one the last menu button DOES change to yellow image when the rest of the menu is selected from top to bottom.  

Now it my task to call lower California and discuss the fix.

Thank you respectfully,

James Avakian, webmaster@productlist.com

Visit www.productlist.com anytime.
0
tecbuilderCommented:
May I post an answer to this question then?
0
opticalAuthor Commented:
As of this monent the answer is still not solved, since the function 'onmouse' is not fully implemented, I know the code your solution is correct, but I am not entirely sure why one browser works like it does and the other ignores it....

Please wait for a complete solution, I (we) may be embarrased if someone at my host made a Style Sheet to directly make our code be ignored.

Sincerely,

James Avakian, webmaster@productlist.com
Optical Automation
0
tecbuilderCommented:
Do you still get an error with MSIE 4.x or does it just not do anything?
0
opticalAuthor Commented:
MSIE 4.x operates as if funct 'onmouse' was not there...

Visit www.productlist.com, also try Netscape, very interesting...
0
tecbuilderCommented:
Just checking... You do have JavaScript enabled on your MSIE 4.x browser?
0
opticalAuthor Commented:
Regarding MSIE v4.01, there is no setting to enable JavaScript.

The line 'new Image(113, 27)' in the code are 113 and 27 the height and width or are they coordinates ?
0
tecbuilderCommented:
There should be a setting to enable or disable scripting in MSIE.  It would be in the same place that you can enable or disable Java.  I wish I could tell you more about it, I am just relaying what I've heard.

The 113, 27 are the height and width.  But these get overwritten by your image tag.
0
opticalAuthor Commented:
Why does only the last image in the table change from white to yellow ?
0
tecbuilderCommented:
It is because the same name is used in all of the images ie. imgName.  This should be changed to mailx where x = 1-8.  Did you get the updated file I sent you today?
0
opticalAuthor Commented:
I didn't recieve your file.  Your suggestion to change imgName to imgNameX where X is to be 1 through 8, is already implemented as suggested by you in the onmouseout="imgInactive('menu1')" statement in each table area as menu1 through menu8 ? Please restate your suggestion ?  visit www.productlist.com again now now image white to yellow changes in either MSIE or netscape ?
0
tecbuilderCommented:
Did you ever figure out the problem with MSIE 4.x?  I did check out your site and was glad to see that everything was working like you wanted it to.  At least for Netscape and MSIE 3.x.
0
serobertCommented:
If what you are trying to do is use mouseover to get an image to change, I have a significantly easier method of doing so.  This method functions in all javascript enabled browsers that I have tested it in (including MSIE 4.x).  It also takes up significantly fewer lines of code.  The code is as follows:

<html>

<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta NAME="GENERATOR" CONTENT="Microsoft FrontPage 3.0">
<title>Index Links</title>
<script language="JavaScript">
<!--
function change(name,file) {
  if (parseFloat(navigator.appVersion)>2.02)
    eval('document.images["'+name+'"].src="'+file+'"')
}
//-->
</script>
</head>

<body BGCOLOR="#FFFFFF">

<p align="center">&nbsp; </p>
<div align="center"><center>

<table BORDER="0" CELLPADDING="0" WIDTH="125" HEIGHT="302">
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="117"><a HREF="signin_a.html" target="center"><img
 SRC="shopper_lady_mini.gif" ALT="See The ProductList Newtork®" BORDER="0" HEIGHT="108"
 WIDTH="120"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="signin_a.htm" target="center" onMouseOver="change('menu1','title_software_c.gif');" onmouseout="change('menu1','title_software.gif');"><img
 SRC="title_software.gif" name="menu1" ALT="ProductList Software !" BORDER="0"
 HEIGHT="25" WIDTH="113" ALIGN="CENTER"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="toc_index.htm" target="center" onMouseOver="change('menu2','distrib_txt2.jpg');" onmouseout="change('menu2','title_site_contents.gif');"><img
 SRC="title_site_contents.gif" name="menu2" ALT="Table of Contents" BORDER="0"
 HEIGHT="25" WIDTH="113" ALIGN="CENTER"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="g_interest.htm" target="center" onMouseOver="change('menu3,'title_site_general_c.gif');" onmouseout="change('menu3','title_site_general.gif');"><img
 SRC="title_site_general.gif" name="menu3" ALT="Articles Of Interest" BORDER="0"
 HEIGHT="25" WIDTH="113" ALIGN="CENTER"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="tech_focus.html" target="center" onMouseOver="change('menu4','title_tech_focus_c.gif');" onmouseout="change('menu4','title_tech_focus.gif');"><img
 SRC="title_tech_focus.gif" name="menu4" ALT="Tech Focus Articles Of Interest" BORDER="0"
 HEIGHT="25" WIDTH="113" ALIGN="CENTER"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="newtons_web.html" target="_top" onMouseOver="change('menu5','title_newtons_web_c.gif');" onmouseout="change('menu5','title_newtons_web.gif');"><img
 SRC="title_newtons_web.gif" name="menu5" ALT="Newton's Web!" BORDER="0" HEIGHT="25"
 WIDTH="113" ALIGN="CENTER"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="news0.htm" target="center" onMouseOver="change('menu6','title_news.gif.jpg');" onmouseout="change('menu6','title_news.gif');"><img
 SRC="title_news.gif" name="menu6" ALT="News Events" BORDER="0" HEIGHT="25" WIDTH="113"
 ALIGN="CENTER"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="site_develop_a.html" target="center" onMouseOver="change('menu7','title_sample_c.gif');" onmouseout="change('menu7','title_sample.gif');"><img
 SRC="title_sample.gif" name="menu7" ALT="Site Descriptions and Samples" BORDER="0"
 HEIGHT="25" WIDTH="113" ALIGN="CENTER"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="26"><a HREF="n_search.htm" target="center" onMouseOver="change('menu8','title_search_c.gif');" onmouseout="change('menu8','title_search.gif');"><img
 SRC="title_web_search.gif" name="menu8" ALT="Internet Search" BORDER="0" HEIGHT="25"
 WIDTH="113" ALIGN="CENTER"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="29"></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="29"><a HREF="audio_on.html" target="center"><img
 SRC="speaker.gif" ALT="Speakers / Sound On ?" BORDER="0" HEIGHT="31" WIDTH="22"
 ALIGN="CENTER"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="29"><a HREF="index_specials.htm" target="center"><img
 SRC="special.gif" ALT="special" BORDER="1" HEIGHT="16" WIDTH="65" ALIGN="CENTER"></a></td>
</tr>
<tr>
 <td ALIGN="CENTER" WIDTH="126" HEIGHT="29"><blockquote>
 <a HREF="toc_specials.htm#bottom" target="center"><p align="center"><img SRC="bullet2.gif"
 ALT="Daily Essentials . . ." BORDER="0" HEIGHT="10" WIDTH="7"></a> </p>
 </blockquote>
 </td>
</tr>
</table>
</center></div>

<p>&nbsp; </p>
</body>
</html>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tecbuilderCommented:
serobet, the script that I have posted and that optical is using at his site also works with MSIE 4.x.  However, the problem isn't with the script, rather it seems to be his server.  I also have used the same script on MSIE 4.x and it works there as well.  Your answer really doesn't add anything more to the question than what was already posted.  Your answer also does not preload the graphics which is what optical wanted to do, hence all the additional lines of code he has.  To use your method, if a person ran their cursor over the button (not stopping), the button would not change because the image has not been loaded yet.
0
opticalAuthor Commented:
I like your comment since is smaller code, although
this new code does not allow for image size, "botton"
move will not occur therefore percieved button press
cannot be implemented.

I do appreciate this new version it is another good
example about the care and attention your site presents
to developers, thank you once again Experts-Exchange.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.