Welcome to HostingForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Javascript problem

 
   Web Hosting Problem Solving Community! (Home) -> Webmaster RSS
Next:  UK Hosting  
Author Message
telina02

External


Since: Jul 28, 2003
Posts: 32



(Msg. 1) Posted: Mon Jan 26, 2004 2:02 am
Post subject: Javascript problem
Archived from groups: alt>www>webmaster (more info?)

Is there anyone here who would be willing to help my with a navigation bar?
I need to have it working by tomorrow.

It works fine on a page by itself - but when pasted into the page it's
designed for, it's completely non-functional. I've been over the code to
make sure filenames are correct, and have made sure that all the images are
in the same directory. Don't know what else to check.

The code is pasted below - don't dare post the links, but I could email
them...

Thx,
TL

--------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Navigation Bar</title>

<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
x.src=x.oSrc;
}

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[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
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[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document); 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[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<body bgcolor="#FFFFFF" text="#000000" link="#00CCCC" vlink="#00CC99"
alink="#FFCC66"
onLoad="MM_preloadImages('hometop-sm.jpg','eventstop-sm.jpg','articletop-sm.
jpg','indextop-sm.jpg','missiontop-sm.jpg','findustop-sm.jpg','contacttop-sm
..jpg')">

<div id="navbar" align="left" style="width:750px; height:89px;
background-color:#000000;">
<p><img src="navtop-subtl-sm.jpg" width="750" height="37" align="top"><br>
<a
href="index.html"onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage('
homebutn','','hometop-sm.jpg',1)"><img src="navspc-subt-sml.gif" width="50"
height="30" border="0"><img name="homebutn" border="0" src="home-sm.jpg"
width="84" height="30"></a><a
href="articles.html"onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImag
e('articlebutn','','articletop-sm.jpg',1)"></a><a
href="events.html"onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage(
'eventsbutn','','eventstop-sm.jpg',1)"><img name="eventsbutn" border="0"
src="events-sm.jpg" width="84" height="30"></a><a
href="articles.html"onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImag
e('articlebutn','','articletop-sm.jpg',1)"><img name="articlebutn"
border="0" src="articles-sm.jpg" width="84" height="30"></a><a
href="z-index.html"onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage
('index','','indextop-sm.jpg',1)"><img name="index" border="0"
src="index-sm.jpg" width="84" height="30"></a><a
href="mission.html"onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage
('missionbutn','','missiontop-sm.jpg',1)"><img name="missionbutn" border="0"
src="mission-sm.jpg" width="84" height="30"></a><a
href="findus.html"onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage(
'findbutn','','findustop-sm.jpg',1)"><img name="findbutn" border="0"
src="findus-sm.jpg" width="84" height="30"></a><a
href="contact.html"onMouseOut="MM_swapImgRestore()"onMouseOver="MM_swapImage
('contactbutn','','contacttop-sm.jpg',1)"><img name="contactbutn" border="0"
src="contact-sm.jpg" width="84" height="30"></a><img
src="navbtm-subtl-sm.jpg" width="750" height="22"></p>

</div><!-- id="navbar" -->

</body>
</html>

 >> Stay informed about: Javascript problem 
Back to top
Login to vote
gary1

External


Since: Jul 01, 2003
Posts: 50



(Msg. 2) Posted: Mon Jan 26, 2004 2:44 am
Post subject: Re: Javascript problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <UVXQb.27417$zj7.265@newsread1.news.pas.earthlink.net>,
telina02.RemoveThis@ziplip.com says...
 > Is there anyone here who would be willing to help my with a navigation bar?
 > I need to have it working by tomorrow.
 >
 > It works fine on a page by itself - but when pasted into the page it's
 > designed for, it's completely non-functional. I've been over the code to
 > make sure filenames are correct, and have made sure that all the images are
 > in the same directory. Don't know what else to check.
 >
 > The code is pasted below - don't dare post the links, but I could email
 > them...

{snip}

Seems to be missing spaces before the onmouse... attributes.
e.g.
<a
href="index.html"onMouseOut="MM_swapImgRestore
()"onMouseOver="MM_swapImage('
homebutn','','hometop-sm.jpg',1)">

needs to be:

<a
href="index.html" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('homebutn','','hometop-sm.jpg',1)">

Should solve the problem. A case of looking at the code too much to see
the obvious. (Plus that the code isn't the prettiest in the first
place).

I'd also throw in that it should be <script type="text/javascript">
rather than <script language="Javascript">.
Then there's some CSS issues I'd pick up on, unit clarification in your
<img> HTML, the fact you're using JS in the first place, etc etc...but
as you only asked why the menu wasn't working, I'll stop Surprised)

Gazza<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Javascript problem 
Back to top
Login to vote
telina02

External


Since: Jul 28, 2003
Posts: 32



(Msg. 3) Posted: Mon Jan 26, 2004 3:36 am
Post subject: Re: Javascript problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Gazza wrote in message ...
 >In article <UVXQb.27417$zj7.265@newsread1.news.pas.earthlink.net>,
 >telina02@ziplip.com says...

 >Seems to be missing spaces before the onmouse... attributes.
 >e.g.
 ><a
 >href="index.html"onMouseOut="MM_swapImgRestore
 >()"onMouseOver="MM_swapImage('
 >homebutn','','hometop-sm.jpg',1)">
 >
 >needs to be:
 >
 ><a
 >href="index.html" onMouseOut="MM_swapImgRestore()"
 >onMouseOver="MM_swapImage('homebutn','','hometop-sm.jpg',1)">
 >
 >Should solve the problem. A case of looking at the code too much to see
 >the obvious. (Plus that the code isn't the prettiest in the first
 >place).

Thanks, I'll try that.

DW generated the code - nuff said. I've created this thing three times
now - in Fireworks, Imagestyler, and DW. The DW version is the only one
that came close to working.

 >I'd also throw in that it should be <script type="text/javascript">
 >rather than <script language="Javascript">.
 >Then there's some CSS issues I'd pick up on, unit clarification in your
 ><img> HTML, the fact you're using JS in the first place, etc etc...but
 >as you only asked why the menu wasn't working, I'll stop Surprised)

Points taken. :^)
Client requested the JS buttons. I normally use text links.

TL<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Javascript problem 
Back to top
Login to vote
gary1

External


Since: Jul 01, 2003
Posts: 50



(Msg. 4) Posted: Mon Jan 26, 2004 4:40 am
Post subject: Re: Javascript problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <aiZQb.27541$zj7.1654@newsread1.news.pas.earthlink.net>,
telina02.DeleteThis@ziplip.com says...

 > DW generated the code - nuff said. I've created this thing three times
 > now - in Fireworks, Imagestyler, and DW. The DW version is the only one
 > that came close to working.

IIRC, you can edit the templates that DW uses for bits and pieces like
that - like <a style='text-decoration: underline;' href="http://www.alistapart.com/articles/dreamweaver/" target="_blank">http://www.alistapart.com/articles/dreamweaver/</a> does for
producing XHTML rather than HTML. Might be worth playing to see if you
can tweak it so it produces working JS/HTML...

--
Gazza
<a style='text-decoration: underline;' href="http://www.rossmore.org/" target="_blank">http://www.rossmore.org/</a>
<a style='text-decoration: underline;' href="http://www.garyjones.co.uk/" target="_blank">http://www.garyjones.co.uk/</a>
"Some people don't listen, then simply wait to speak"<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Javascript problem 
Back to top
Login to vote
telina02

External


Since: Jul 28, 2003
Posts: 32



(Msg. 5) Posted: Mon Jan 26, 2004 9:01 am
Post subject: Re: Javascript problem [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Gazza wrote in message ...
 >In article <aiZQb.27541$zj7.1654@newsread1.news.pas.earthlink.net>,
 >telina02@ziplip.com says...
 >
  >> DW generated the code - nuff said. I've created this thing three times
  >> now - in Fireworks, Imagestyler, and DW. The DW version is the only one
  >> that came close to working.
 >
 >IIRC, you can edit the templates that DW uses for bits and pieces like
 >that - like <a style='text-decoration: underline;' href="http://www.alistapart.com/articles/dreamweaver/" target="_blank">http://www.alistapart.com/articles/dreamweaver/</a> does for
 >producing XHTML rather than HTML. Might be worth playing to see if you
 >can tweak it so it produces working JS/HTML...

I've got to get this thing working by tomorrow.

Tried your suggestion but it's still broken. It appears that for some
reason the browser isn't loading the mouseover image.

There's another script on the page right now, standing in for a custom
calendar that will be linked to a db. I'm thinking maybe these two scripts
are fighting each other somehow? Just in case that appears obvious, the
code is pasted below.

TL

-------------

text of linked calendar script:

function buildCal(m, y, cM, cH, cDW, cD, brdr){
var
mn=['January','February','March','April','May','June','July','August','Septe
mber','October','November','December'];
var dim=[31,0,31,30,31,30,31,31,30,31,30,31];

var oD = new Date(y, m-1, 1); //DD replaced line to fix date bug when
current day is 31st
oD.od=oD.getDay()+1; //DD replaced line to fix date bug when current day is
31st

var todaydate=new Date() //DD added
var scanfortoday=(y==todaydate.getFullYear() && m==todaydate.getMonth()+1)?
todaydate.getDate() : 0 //DD added

dim[1]=(((oD.getFullYear()%100!=0)&&(oD.getFullYear()%4==0))||(oD.getFullYea
r()%400==0))?29:28;
var t='<div class="'+cM+'"><table class="'+cM+'" cols="7" cellpadding="0"
border="'+brdr+'" cellspacing="0"><tr align="center">';
t+='<td colspan="7" align="center" class="'+cH+'">'+mn[m-1]+' -
'+y+'</td></tr><tr align="center">';
for(s=0;s<7;s++)t+='<td class="'+cDW+'">'+"SMTWTFS".substr(s,1)+'</td>';
t+='</tr><tr align="center">';
for(i=1;i<=42;i++){
var x=((i-oD.od>=0)&&(i-oD.od<dim[m-1]))? i-oD.od+1 : ' ';
if (x==scanfortoday) //DD added
x='<span id="today">'+x+'</span>' //DD added
t+='<td class="'+cD+'">'+x+'</td>';
if(((i)%7==0)&&(i<36))t+='</tr><tr align="center">';
}
return t+='</tr></table></div>';
}

--------------------------
what's actually on the page can be seen below
--------------------------

<script type="text/javascript" src="basiccalendar.js">

/***********************************************
* Basic Calendar-By Brian Gosselin at <a style='text-decoration: underline;' href="http://scriptasylum.com/bgaudiodr/" target="_blank">http://scriptasylum.com/bgaudiodr/</a>
* Script featured on Dynamic Drive (http://www.dynamicdrive.com)
* This notice must stay intact for use
* Visit <a style='text-decoration: underline;' href="http://www.dynamicdrive.com/" target="_blank">http://www.dynamicdrive.com/</a> for full source code
***********************************************/

<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++)
x.src=x.oSrc;
}

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[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
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[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document); 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[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc)
x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

<!--calendar script entry-->
<script type="text/javascript">

var todaydate=new Date()
var curmonth=todaydate.getMonth()+1 //get current month (1-12)
var curyear=todaydate.getFullYear() //get current year

document.write(buildCal(curmonth ,curyear, "main", "month", "daysofweek",
"days", 1));
</script><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Javascript problem 
Back to top
Login to vote
Display posts from previous:   
   Web Hosting Problem Solving Community! (Home) -> Webmaster All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]