JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 16th, 2004, 01:48 AM
0riole 0riole is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Melbourne Australia
Posts: 2 0riole User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with JavaScript

Hi All,

Need some help with the following script, it works great in Opera and IE, but no joy in Mozilla or Netscape, can some onr please help.

Thanks,
Chris
--------------------------------------------------


<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
var mfBanners = [
<!-- ['link url', 'image url'}. -->
['http://url1', 'images/banner1.gif'],
['http://url2', 'images/banner2.gif'],
['http://url3', 'images/banner3.gif'],
['http://url4', 'images/banner4.gif'],
['http://url5', 'images/banner5.gif'],
];
var mfIe = false;
if( document.all) {
mfIe = true;
}
var mfBannerIndex = 0;
function mfBannerChange() {
var htmlString = '<a href="'+mfBanners[mfBannerIndex][0]+'"> <img border="0" src="'+mfBanners[mfBannerIndex][1]+'"></a>';
if( mfIe) {
document.all.banner.innerHTML = htmlString;
}
else {
document.layers["banner"].document.open();
document.layers["banner"].document.write();
document.layers["banner"].document.close();
}
if(mfBannerIndex < mfBanners.length - 1)
mfBannerIndex++;
else
mfBannerIndex = 0;
}
setInterval("mfBannerChange()", 4000);
</script>
</head>
<body bgcolor="black">
<table border="0" width=100%">
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td height="165"><center>&nbsp;<br><div id="banner"></div></center></td>
</table>
</body>
</html>

Reply With Quote
  #2  
Old May 16th, 2004, 10:00 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
The whole "all" and "layers" method of accessing layers is no longer used, as it was browser dependant. Instead, use the getElementById() method as it is more widely accepted in the newer browsers.

Reply With Quote
  #3  
Old May 16th, 2004, 08:41 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
http://www.jsexamples.com/js/
This site has a tonne of examples.

Reply With Quote
  #4  
Old May 16th, 2004, 10:02 PM
0riole 0riole is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Melbourne Australia
Posts: 2 0riole User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Solved

Thanks Stumpy I replaced
document.layers["banner"].document.open();
document.layers["banner"].document.write();
document.layers["banner"].document.close();

with

document.getElementById('banner').innerHTML = htmlString;

All happy in Mozilla/Netscape land

Chris

Reply With Quote
  #5  
Old May 16th, 2004, 10:33 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Posts: 2,056 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 44 m 22 sec
Reputation Power: 0
Nice one! Much neater too.

Reply With Quote
  #6  
Old May 21st, 2004, 09:10 AM
pocketsized pocketsized is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Brunei
Posts: 26 pocketsized User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Just thought I'd add that innerHTML is proprietary. Use DOM standards instead. I've linked an article from http://www.alistapart.com that demonstrates an alternative to using innerHTML.

http://www.alistapart.com/articles/imagegallery/

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Help with JavaScript


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap