Script Error

H

Helpless Soul

I am getting the following error on a webpage:

Char 1
Error Object Expected
Code 0


Here is the page source that's throwing the error:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Test Page</title>
<meta http-equiv="content-language" content="en-us" />

<meta http-equiv="imagetoolbar" content="no" />
<meta name="mssmarttagspreventparsing" content="true" />

<meta name="description" content="content here" />

<meta name="keywords" content="test1,test2" />

<meta name="author" content="solutions" />

<style type="text/css" media="all">
@import "css/master.css";
@import "css/homepage.css";
</style>
<script type="text/javascript" src="script.js"></script>

</head>

<body
onload="mm_preloadimages('imagery/menu/aboutus_over.jpg','imagery/menu/membership_over.jpg','imagery/menu/racehorses_over.jpg','imagery/menu/trainers_over.jpg','imagery/menu/news_over.jpg','imagery/menu/racecourse_over.jpg','imagery/menu/bloodstock_over.jpg','imagery/menu/contact_over.jpg','imagery/menu/links_over.jpg');">

<div id="header"><img src="imagery/general/header.jpg" alt="alt text"
width="696" height="81" /></div>

<div id="container">

<div id="leftcolumn">

<div id="menu">

<div id="button"><a href="index.htm"><img
src="imagery/menu/home_over.jpg" alt="home" name="home" width="155"
height="22" border="0" id="home"
onmouseover="mm_swapimage('home','','imagery/menu/home_over.jpg',1)"
onmouseout="mm_swapimgrestore()" /></a></div>
<div id="button"><a href="aboutus.htm"><img
src="imagery/menu/aboutus.jpg" alt="about us" name="about" width="155"
height="22" border="0" id="about"
onmouseover="mm_swapimage('about','','imagery/menu/aboutus_over.jpg',1)"
onmouseout="mm_swapimgrestore()" /></a></div>
<div id="button"><a href="membership.htm"><img
src="imagery/menu/membership.jpg" alt="membership" name="membership"
width="155" height="22" border="0" id="membership"
onmouseover="mm_swapimage('membership','','imagery/menu/membership_over.jpg',1)"
onmouseout="mm_swapimgrestore()" /></a></div>
<div id="button"><a href="ownershipshare.htm"><img
src="imagery/menu/ownership.jpg" alt="ownerhip share" name="ownership"
width="155" height="22" border="0" id="ownership"
onmouseover="mm_swapimage('ownership','','imagery/menu/ownership_over.jpg',1)"
onmouseout="mm_swapimgrestore()" /></a></div>
<div id="button"><a href="racehorses.htm"><img
src="imagery/menu/racehorses.jpg" alt="racehorses" name="racehorses"
width="155" height="22" border="0" id="racehorses"
onmouseover="mm_swapimage('racehorses','','imagery/menu/racehorses_over.jpg',1)"
onmouseout="mm_swapimgrestore()" /></a></div>
<div id="button"><a href="trainers.htm"><img
src="imagery/menu/trainers.jpg" alt="trainers" name="trainers"
width="155" height="22" border="0" id="trainers"
onmouseover="mm_swapimage('trainers','','imagery/menu/trainers_over.jpg',1)"
onmouseout="mm_swapimgrestore()" /></a></div>
<div id="button"><a href="news.htm"><img src="imagery/menu/news.jpg"
alt="news &amp; results" name="news" width="155" height="22" border="0"
id="news"
onmouseover="mm_swapimage('news','','imagery/menu/news_over.jpg',1)"
onmouseout="mm_swapimgrestore()" /></a></div>
<div id="button"><a href="contactus.htm"><img
src="imagery/menu/contact.jpg" alt="contact us" name="contact"
width="155" height="22" border="0" id="contact"
onmouseover="mm_swapimage('contact','','imagery/menu/contact_over.jpg',1)"
onmouseout="mm_swapimgrestore()" /></a></div>
<div id="button"><a href="links.htm"><img
src="imagery/menu/links.jpg" alt="links" name="links" width="155"
height="22" border="0" id="links"
onmouseover="mm_swapimage('links','','imagery/menu/links_over.jpg',1)"
onmouseout="mm_swapimgrestore()" /></a></div>
</div>

</body>
</html>


Can anyone help me solve this riddle?

Thanks
Soul
 
H

Harlan Messinger

I'm a little uncertain about how to ask you the obvious question,
because if you understand that this is a scripting error, then it would
certainly have occurred to you that one would need to see the script in
order to debug it, and if you don't know that it's a scripting error and
don't know what "script" is then I wouldn't expect you to have been
given the assignment of debugging this error.
 
H

Helpless Soul

It's a website I inherited, that's why I am looking at it.

Here is the script (script.js):

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}


HTH


SOul
 
H

Harlan Messinger

Helpless said:
It's a website I inherited, that's why I am looking at it.

Here is the script (script.js):

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a;}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++)
x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}


This is ancient, oft-pasted code that may still work in all the
mainstream browsers for preloading images and creating rollovers, except
for one thing: Javascript is case-sensitive. A function named
MM_preloadImages is not going to be executed by code that calls a
function named mm_preloadimages, and likewise for the remaining
functions. Fix this in your HTML page.
 
T

Travis Newbury

Can anyone help me solve this riddle?

Probably not without a URL. Or were you expecting us to create a
dummy page, post your code in it, debug it, and post your solution
here.
 
H

Helpless Soul

Harlan said:
Helpless said:
It's a website I inherited, that's why I am looking at it.

Here is the script (script.js):

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a;}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}


This is ancient, oft-pasted code that may still work in all the
mainstream browsers for preloading images and creating rollovers, except
for one thing: Javascript is case-sensitive. A function named
MM_preloadImages is not going to be executed by code that calls a
function named mm_preloadimages, and likewise for the remaining
functions. Fix this in your HTML page.


I think that is incorrect - the page does "work" but throws the error.
Several near identical pages also work flawlessly.
Soul
 
H

Harlan Messinger

Helpless said:
Harlan said:
Helpless said:
It's a website I inherited, that's why I am looking at it.

Here is the script (script.js):

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a;}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}


This is ancient, oft-pasted code that may still work in all the
mainstream browsers for preloading images and creating rollovers,
except for one thing: Javascript is case-sensitive. A function named
MM_preloadImages is not going to be executed by code that calls a
function named mm_preloadimages, and likewise for the remaining
functions. Fix this in your HTML page.


I think that is incorrect - the page does "work" but throws the error.
Several near identical pages also work flawlessly.


No, it doesn't work, and when I changed the case of the function names
in the HTML file to match the case in the JS file, the error went away. OK?
 
H

Helpless Soul

Harlan said:
Helpless said:
Harlan said:
Helpless Soul wrote:
It's a website I inherited, that's why I am looking at it.

Here is the script (script.js):

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a;}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for
(i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x;
if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

This is ancient, oft-pasted code that may still work in all the
mainstream browsers for preloading images and creating rollovers,
except for one thing: Javascript is case-sensitive. A function named
MM_preloadImages is not going to be executed by code that calls a
function named mm_preloadimages, and likewise for the remaining
functions. Fix this in your HTML page.


I think that is incorrect - the page does "work" but throws the error.
Several near identical pages also work flawlessly.


No, it doesn't work, and when I changed the case of the function names
in the HTML file to match the case in the JS file, the error went away. OK?


My test last night didn't confirm that, but I have re-read your post and
it seems that I overlooked some of the caps. In fact, I only changed the
MM to mm (no you know where I got my posting nick from).
I will have another go and report back.
Thanks a lot Harlan.

Soul
 
H

Hopeless

Helpless said:
Harlan said:
Helpless said:
Harlan Messinger wrote:
Helpless Soul wrote:
It's a website I inherited, that's why I am looking at it.

Here is the script (script.js):

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a;}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for
(i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x;
if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

This is ancient, oft-pasted code that may still work in all the
mainstream browsers for preloading images and creating rollovers,
except for one thing: Javascript is case-sensitive. A function named
MM_preloadImages is not going to be executed by code that calls a
function named mm_preloadimages, and likewise for the remaining
functions. Fix this in your HTML page.

I think that is incorrect - the page does "work" but throws the
error. Several near identical pages also work flawlessly.


No, it doesn't work, and when I changed the case of the function names
in the HTML file to match the case in the JS file, the error went
away. OK?


My test last night didn't confirm that, but I have re-read your post and
it seems that I overlooked some of the caps. In fact, I only changed the
MM to mm (no you know where I got my posting nick from).
I will have another go and report back.
Thanks a lot Harlan.

Soul



OK, still couldn't get it to work. Wasn't sure whether I should change
the script to all lower case, or change the html? I tried both and
neither worked. As I already said, my linked pages that have the same
(well, very similar) menus all work.
Anyway, thanks for your help,

Hopeless
 
B

billbitt96

Helpless said:
Harlan said:
Helpless Soul wrote:
Harlan Messinger wrote:
Helpless Soul wrote:
It's a website I inherited, that's why I am looking at it.
Here is the script (script.js):
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a;}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for
(i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x;
if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
This is ancient, oft-pasted code that may still work in all the
mainstream browsers for preloading images and creating rollovers,
except for one thing: Javascript is case-sensitive. A function named
MM_preloadImages is not going to be executed by code that calls a
function named mm_preloadimages, and likewise for the remaining
functions. Fix this in your HTML page.
I think that is incorrect - the page does "work" but throws the
error. Several near identical pages also work flawlessly.
No, it doesn't work, and when I changed the case of the function names
in the HTML file to match the case in the JS file, the error went
away. OK?

My test last night didn't confirm that, but I have re-read your post and
it seems that I overlooked some of the caps. In fact, I only changed the
MM to mm (no you know where I got my posting nick from).
I will have another go and report back.
Thanks a lot Harlan.

OK, still couldn't get it to work. Wasn't sure whether I should change
the script to all lower case, or change the html? I tried both and
neither worked. As I already said, my linked pages that have the same
(well, very similar) menus all work.
Anyway, thanks for your help,

Hopeless


Did you ever solve this or everyone dropped the issue. Maybe I am not
looking everywhere but it seems that mm_sr is not defined anywhere. It
is some kind of array based on the document model in your browser. Can
you show me the code where its defined? Better yet, cut and paste one
of your other functions which are working, you referred to those. You
said some are working but this one doesn't work. Let me look them over
and see where its all defined in those and compare the two of them.
Trouble is on posts like this we always just get the broken code and
trial and error or reading it is the only way to find bugs. It could
be something like a hidden character as well. Let met try to adapt
peice by peice some code that works already and I'll get back to you
for this one that's broken. Its my approach, step by step, not trying
to eat the entire pie at once. I have this on in my Sharepoint
Developer already and I doing it the hard way now. But if you send me
one that is working I can compare faster.
 
B

billbitt96

Helpless said:
Harlan Messinger wrote:
Helpless Soul wrote:
Harlan Messinger wrote:
Helpless Soul wrote:
It's a website I inherited, that's why I am looking at it.
Here is the script (script.js):
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a;}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for
(i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x;
if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
This is ancient, oft-pasted code that may still work in all the
mainstream browsers for preloading images and creating rollovers,
except for one thing: Javascript is case-sensitive. A function named
MM_preloadImages is not going to be executed by code that calls a
function named mm_preloadimages, and likewise for the remaining
functions. Fix this in your HTML page.
I think that is incorrect - the page does "work" but throws the
error. Several near identical pages also work flawlessly.
No, it doesn't work, and when I changed the case of the function names
in the HTML file to match the case in the JS file, the error went
away. OK?
My test last night didn't confirm that, but I have re-read your post and
it seems that I overlooked some of the caps. In fact, I only changed the
MM to mm (no you know where I got my posting nick from).
I will have another go and report back.
Thanks a lot Harlan.
Soul

OK, still couldn't get it to work. Wasn't sure whether I should change
the script to all lower case, or change the html? I tried both and
neither worked. As I already said, my linked pages that have the same
(well, very similar) menus all work.
Anyway, thanks for your help,

Did you ever solve this or everyone dropped the issue. Maybe I am not
looking everywhere but it seems that mm_sr is not defined anywhere. It
is some kind of array based on the document model in your browser. Can
you show me the code where its defined? Better yet, cut and paste one
of your other functions which are working, you referred to those. You
said some are working but this one doesn't work. Let me look them over
and see where its all defined in those and compare the two of them.
Trouble is on posts like this we always just get the broken code and
trial and error or reading it is the only way to find bugs. It could
be something like a hidden character as well. Let met try to adapt
peice by peice some code that works already and I'll get back to you
for this one that's broken. Its my approach, step by step, not trying
to eat the entire pie at once. I have this on in my Sharepoint
Developer already and I doing it the hard way now. But if you send me
one that is working I can compare faster.


Put this at the top of all your scripts you need the type of script or
it will never run in new browsers:

<script type="text/javascript" LANGUAGE="JavaScript">

Put this at the bottom:
</script>
 
A

Adrienne Boswell

Gazing into my crystal ball I observed billbitt96 <[email protected]>
writing in @y21g2000hsf.googlegroups.com:
Put this at the top of all your scripts you need the type of script or
it will never run in new browsers:

<script type="text/javascript" LANGUAGE="JavaScript">

Put this at the bottom:
</script>

You do need type, but language is deprecated. Of course, even better is
an external script, eg. <script type="text/javascript"
src="masterfunctions.js"></script>.
 
H

Helpless Soul

billbitt96 said:
Helpless Soul wrote:
Harlan Messinger wrote:
Helpless Soul wrote:
Harlan Messinger wrote:
Helpless Soul wrote:
It's a website I inherited, that's why I am looking at it.
Here is the script (script.js):
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0;
i<a.length; i++)
if (a.indexOf("#")!=0){ d.MM_p[j]=new Image;
d.MM_p[j++].src=a;}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr;
for(i=0;a&&i<a.length&&(x=a)&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for
(i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a))!=null){document.MM_sr[j++]=x;
if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
This is ancient, oft-pasted code that may still work in all the
mainstream browsers for preloading images and creating rollovers,
except for one thing: Javascript is case-sensitive. A function named
MM_preloadImages is not going to be executed by code that calls a
function named mm_preloadimages, and likewise for the remaining
functions. Fix this in your HTML page.
I think that is incorrect - the page does "work" but throws the
error. Several near identical pages also work flawlessly.
No, it doesn't work, and when I changed the case of the function names
in the HTML file to match the case in the JS file, the error went
away. OK?
My test last night didn't confirm that, but I have re-read your post and
it seems that I overlooked some of the caps. In fact, I only changed the
MM to mm (no you know where I got my posting nick from).
I will have another go and report back.
Thanks a lot Harlan.
Soul
OK, still couldn't get it to work. Wasn't sure whether I should change
the script to all lower case, or change the html? I tried both and
neither worked. As I already said, my linked pages that have the same
(well, very similar) menus all work.
Anyway, thanks for your help,
Hopeless

Did you ever solve this or everyone dropped the issue. Maybe I am not
looking everywhere but it seems that mm_sr is not defined anywhere. It
is some kind of array based on the document model in your browser. Can
you show me the code where its defined? Better yet, cut and paste one
of your other functions which are working, you referred to those. You
said some are working but this one doesn't work. Let me look them over
and see where its all defined in those and compare the two of them.
Trouble is on posts like this we always just get the broken code and
trial and error or reading it is the only way to find bugs. It could
be something like a hidden character as well. Let met try to adapt
peice by peice some code that works already and I'll get back to you
for this one that's broken. Its my approach, step by step, not trying
to eat the entire pie at once. I have this on in my Sharepoint
Developer already and I doing it the hard way now. But if you send me
one that is working I can compare faster.


Put this at the top of all your scripts you need the type of script or
it will never run in new browsers:

<script type="text/javascript" LANGUAGE="JavaScript">

Put this at the bottom:
</script>


Hi.
No, I never solved the issue.
I have this in the head:
<script type="text/javascript" src="script.js"></script>

The (index) page is designed to highlight linked rollover buttons. The
pages that these link to are the ones that work (they have the same
buttons on them). I've tried cutting the code from these and placing it
in the index page but the script then gave the same error. In the end I
gave up and rewrote the rollover code using this script:

<script language="JavaScript" type="text/javascript">
<!--
function na_preload_img()
{
var img_list = na_preload_img.arguments;
if (document.preloadlist == null)
document.preloadlist = new Array();
var top = document.preloadlist.length;
for (var i=0; i < img_list.length-1; i++) {
document.preloadlist[top+i] = new Image;
document.preloadlist[top+i].src = img_list[i+1];
}
}

function na_change_img_src(name, nsdoc, rpath, preload)
{
var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ?
nsdoc+'.'+name : 'document.all.'+name);
if (name == '')
return;
if (img) {
img.altsrc = img.src;
img.src = rpath;
}
}

function na_restore_img_src(name, nsdoc)
{
var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ?
nsdoc+'.'+name : 'document.all.'+name);
if (name == '')
return;
if (img && img.altsrc) {
img.src = img.altsrc;
img.altsrc = null;
}
}

// -->
</script>


That works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top