/    Sign up×
Community /Pin to ProfileBookmark

chgImg not defined in Firefox

Some time ago with help from this forum I developed a slideshow for my website which works exactly as intended in IE. However I recently discovered it doesn’t work in Firefox. It appears the chgImg and auto commands are not defined in Firefox. Are there equivalents that do work so that I can simply replace one with the other? Or do I need to start again?

Not sure if we are allowed to include links to the page in question but if we are here it is:-

[url]http://www.robsphotographyservices.com/GalleryChurches.htm[/url]

Here is the head code below:-

<!– Begin

var NewImg = [
“images classic framed/St-Basil’s-Cathedral,-Red-Square-2.jpg”,
“images classic framed/Basilica-of-Sacre-Coeur,-Montmartre.jpg”,
“images classic framed/Alexander-Nevsky-Cathedral,-Tallinn-2.jpg”,
];
var NewImgWidth = [“295″,”295″,”600”];// added for width control
var ImgNum = 0;
var ImgLength = NewImg.length – 1;
//Time delay between Slides in milliseconds
var delay = 5000;
var lock = false;
var run = setInterval(“chgImg(1)”, delay);
var lock = true;

function chgImg(direction) {
if (document.images) {
ImgNum = ImgNum + direction;
if (ImgNum > ImgLength) {
ImgNum = 0;
}
if (ImgNum < 0) {
ImgNum = ImgLength;
}
document.slideshow.src = NewImg[ImgNum];
document.slideshow.width = NewImgWidth[ImgNum]; }// added for width control
}
function auto() {
if (lock == true) {
lock = false;
window.clearInterval(run);
}
else if (lock == false) {
lock = true;
run = setInterval(“chgImg(1)”, delay);
}
}

function preloadImages()
{
var imageArr=[];
for (var i=0; i<NewImg.length; i+=1)
{
imageArr[i]=new Image(NewImgWidth[i]);
imageArr[i].src=NewImg[i];
}
}
window.onload=preloadImages;

End –>

and in the body code:-

<td>
<font face=”Verdana” size=”2″ style=”text-align: center” color=”#FFFFFF”>Slideshow&nbsp;- </font>
<a href=”javascript:chgImg(-1)” style=”text-decoration: none”>
<font color=”#000000″ size=”2″>Previous&nbsp</font></a>
<a href=”javascript:auto()” style=”text-decoration: none”>
<font color=”#FFFFFF” size=”2″>Start/Stop&nbsp</font></a>
<a href=”javascript:chgImg(1)” style=”text-decoration: none”>
<font size=”2″ face=”Verdana” color=”#000000″>Next</font></a>
<p style=”text-align: center”>
<img border=”0″ src=”images%20classic%20framed/St-Basil’s-Cathedral,-Red-Square-2.jpg” name=”slideshow” width=”295″ height=”436″>
<td valign=”top” width=”175″ style=”line-height: 150%; margin-bottom: 0″>

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@FangFeb 11.2010 — 2 closing brackets:document.slideshow.width = NewImgWidth[ImgNum]; [COLOR="Red"]}[/COLOR]// added for width control
[COLOR="Red"]}[/COLOR]
Copy linkTweet thisAlerts:
@SulkyrobauthorFeb 11.2010 — Thanks Fang but the number of opening and closing brackets actually do match - that isn't the problem.
Copy linkTweet thisAlerts:
@FangFeb 11.2010 — remove the comments tags:&lt;!-- Begin
End --&gt;
Copy linkTweet thisAlerts:
@SulkyrobauthorFeb 11.2010 — Brilliant Fang - thanks - that works a treat!!
Copy linkTweet thisAlerts:
@iandevlinFeb 11.2010 — Well you had commented out all the code, hence it wasn't being found.
Copy linkTweet thisAlerts:
@SulkyrobauthorFeb 11.2010 — Okay - I can understand that - but with the Begin and End comments included in this code it did work in IE. How can IE and Firefox be so different in this "fundamental" way?

My next question is - is this slideshow likely to work in Safari and Chrome etc?
Copy linkTweet thisAlerts:
@iandevlinFeb 11.2010 — IE can be a bit more forgiving with such things for some reason, am not sure why.

It should do, but the only way to check it is to test it!
Copy linkTweet thisAlerts:
@FangFeb 11.2010 — but with the Begin and End comments included in this code it did work[/QUOTE]30 years ago they were necessary. Not anymore - stop using them!
IE can be a bit more forgiving with such things for some reason, am not sure why[/QUOTE]All browsers are too forgiving. If the browser adhered strictly to the DTD, 99&#37; of pages would fail.
×

Success!

Help @Sulkyrob spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...