PDA

View Full Version : Cross Browser marquee not working for me in IE8



mike_norcross
09-27-2009, 06:39 AM
1) Script Title: Cross Browser marquee

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex2/cmarquee.htm

3) Describe problem: I have the script below on this page (http://www.purplehurricane.com/).



<script language="JavaScript1.2">

/*
Cross browser Marquee script- Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and Terms Of Use, visit http://www.dynamicdrive.com
Credit MUST stay intact
*/

//Specify the marquee's width (in pixels)
var marqueewidth="620px"
//Specify the marquee's height
var marqueeheight="25px"
//Specify the marquee's marquee speed (larger is faster 1-10)
var marqueespeed=2
//configure background color:
var marqueebgcolor="#FFFFFF"
//Pause marquee onMousever (0=no. 1=yes)?
var pauseit=1

//Specify the marquee's content (don't delete <nobr> tag)
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

var marqueecontent='<nobr><font face="Arial"><strong>Quicklinks:&nbsp;&nbsp;<a href="http://www.afctube.com/?q=search/node/fitzgerald+high+school">Prospect Videos</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://forums.scout.com/mb.aspx?S=37">The Vent</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://realradio969.com/">WRDO</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.herald-leader.net/">FHL</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://www.astihosted.com/BHCDCP/DesktopDefault.aspx?tabid=322">FHS</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://www.astihosted.com/BHCDCP/DesktopDefault.aspx?tabid=32">BOE</a>&nbsp;&nbsp;&nbsp;&nbsp;---&nbsp;&nbsp;---&nbsp;&nbsp;---&nbsp;&nbsp;Thanks to the <a href="http://www.purplehurricane.com/sponsors.asp">sponsors</a>:&nbsp;&nbsp;Shannon Dorough at Xtreme Landscaping, Steve and Kathy Taylor at Southern Physical And Occupational Therapy, Sikes McCord at Pioneer Graphics, and The Fitzgerald Athletic Booster Club.&nbsp;&nbsp;Please support these businesses and organizations early and often.&nbsp;&nbsp;They\'re run by some true Cane fans!</strong></font></nobr>';

////NO NEED TO EDIT BELOW THIS LINE////////////
marqueespeed=(document.all)? marqueespeed : Math.max(1, marqueespeed-1) //slow speed down by 1 for NS
var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-9000px">'+marqueecontent+'</span>')
var actualwidth=''
var cross_marquee, ns_marquee

function populate(){
if (iedom){
cross_marquee=document.getElementById? document.getElementById("iemarquee") : document.all.iemarquee
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
cross_marquee.innerHTML=marqueecontent
actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth
}
else if (document.layers){
ns_marquee=document.ns_marquee.document.ns_marquee2
ns_marquee.left=parseInt(marqueewidth)+8
ns_marquee.document.write(marqueecontent)
ns_marquee.document.close()
actualwidth=ns_marquee.document.width
}
lefttime=setInterval("scrollmarquee()",20)
}
window.onload=populate

function scrollmarquee(){
if (iedom){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
else
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"

}
else if (document.layers){
if (ns_marquee.left>(actualwidth*(-1)+8))
ns_marquee.left-=copyspeed
else
ns_marquee.left=parseInt(marqueewidth)+8
}
}

if (iedom||document.layers){
with (document){
document.write('<table border="0" cellspacing="0" cellpadding="0"><td>')
if (iedom){
write('<div style="position:relative;width:'+marqueewidth+';height:'+marqueeheight+';overflow:hidden">')
write('<div style="position:absolute;width:'+marqueewidth+';height:'+marqueeheight+';background-color:'+marqueebgcolor+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed">')
write('<div id="iemarquee" style="position:absolute;left:0px;top:0px"></div>')
write('</div></div>')
}
else if (document.layers){
write('<ilayer width='+marqueewidth+' height='+marqueeheight+' name="ns_marquee" bgColor='+marqueebgcolor+'>')
write('<layer name="ns_marquee2" left=0 top=0 onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=marqueespeed"></layer>')
write('</ilayer>')
}
document.write('</td></table>')
}
}
</script>


I LOVE the script and it has been working fine for several years. It still works in the latest versions of Firefox, Chrome, and Opera. However, nothing shows up in IE8. It was working in IE7, but not in IE8. Does anyone have any idea why it's not showing up?

Any help would be appreciated.

Mike

jscheuer1
09-27-2009, 07:31 AM
Works fine here in IE 8. Although it seems fine, or at least OK in the various modes that IE 8 can view the page in, perhaps you would have luck by forcing IE 7 mode. To do so, place this meta tag:


<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">


right before your title tag, ex:


<HTML><HEAD>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7">
<TITLE>Fitzgerald High School Purple Hurricane</TITLE>


Also I notice that your page has at least two heads, this is not allowed by W3C standards and can cause problems sometimes in one or more browsers. One and only one head should be used.

mike_norcross
09-27-2009, 07:17 PM
Thanks for responding, John.

Unfortunately, I'm not much of a programmer. I kind of "frankenstein" things together and that pushes the limits of my knowledge.

Regarding the two heads, I use an include (asp) file for my header that is repeated on every page. It has its own head. Then, each page that has content has its own head. Thus, I have two heads on each page. I don't really know another way to do it since I have info I need to put in each head. However...

** I did take the header include file off my default.asp and viewed the default.asp as a standalone page. That left it with one head. The script still didn't work in IE8.

** I tried putting in the meta tag to force IE7 mode. I still couldn't see the script in IE8.

It's weird that you see the marquee in IE8 and I don't. I tried to look for some setting I had in IE8 that was blocking scripts, but I didn't have any such setting. I'm using all the default settings that came when I "upgraded" to IE8. I didn't change anything.

NOW, though, I think I made have found a solution or workaround. I noticed another script on my page that started with this --

<script language="JavaScript">

instead of this --

<script language="JavaScript1.2">

I changed the dynamicdrive.com script to language="JavaScript" (taking off the 1.2) and now it seems to work in IE8. It also still works in Firefox. So I think I'm okay now. Can you check to see if the marquee still works in your IE8 browser? Here is the page it's on: http://www.purplehurricane.com.

Why would that small change make a difference? Do you know? Did something change in JavaScript 1.2? I'm confused. I'm glad I have a solution (or so it appears), but I'm confused as to why the change was necessary -- even if it was only necessary for my browser or select browsers.

Thanks again for your help.

Mike

jscheuer1
09-28-2009, 12:17 AM
Yup, still working here in IE 8. As to your confusion about the language attribute in the script tag, it is really rather simple. The language attribute has been deprecated. It should no longer be used. If you do use it, it's a crap shoot as to how any given browser will react to it. At this writing, and for the foreseeable future, the only two proper ways to make a javascript script tag are like so -

for on page scripts:


<script type="text/javascript">
actual script code goes here
</script>

or for external script tags (the external script is referenced in the src attribute):


<script src="my_script.js" type="text/javascript">
//comments only allowed here (like a credit),
//but not required (unless specified by a script's usage terms),
//they must be preceded by the // single line comment indicator or enclosed in
/* the multi line comment indicator as
these two lines are */
</script>

mike_norcross
09-28-2009, 05:51 PM
Thanks, John. The website admins may want to amend that in the "Cross Browser marquee" code on this page:

http://www.dynamicdrive.com/dynamicindex2/cmarquee.htm

It still reflects JavaScript1.2. That may trip someone else up in the future (like it did me).

jscheuer1
09-28-2009, 08:54 PM
I have enough trouble getting ddadmin to update code that I originally contributed. But you are right. Many older scripts in the library could use updates if only to bring them into conformance with standards. However, owing mostly to time constraints I imagine, ddadmin appears to be choosing to update, often completely rewrite and upgrade the more popular scripts, while leaving some of the older ones to languish. Generally this business with the language attribute shouldn't cause a problem, but it can - and since it is non-standard - anyone who uses it and has a problem cannot really complain about the browser. That said, my IE 8 (which I keep updated with live update) had no problem with it. Which make sense to me because most browser makers want their browsers to be backward compatible even though there is no standard requiring it.