PDA

View Full Version : Marquee help please



baldrn
04-13-2007, 02:33 AM
1) Script Title: FF1+ IE5+ Opr7+ Cross Browser marquee

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

3) Describe problem:
When the words scroll to the left side, it doesn't roll off of the marquee, it just sort of stops.
Here is the code that I am using, altered to the use, of course.
Thanks! I new to DD and love it...thanks folks.

<p align="center"><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="500px"
//Specify the marquee's height
var marqueeheight="50px"
//Specify the marquee's marquee speed (larger is faster 1-10)
var marqueespeed=2
//configure background color:
var marqueebgcolor=""
//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"><b>Shading the homes of West Tennessee since 1999</b></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>

thetestingsite
04-13-2007, 02:42 AM
It seems to work fine for me with the code you posted above (tested in IE6, IE7, and FF 2.0.0.3). To see what I mean, go to http://phphost.smackum.com/dd/marquee.html.

A link to your problem page would help us out in determining whether or not it is something else on your page that is conflicting with the script.

Anyways, hope this helps.

baldrn
04-13-2007, 03:17 AM
If you promise not to laugh at me, I'll show you:
http://jacksoncustomblinds.com/

I'm new at this, so....just look the other way and don't laugh in my face. I'm learning. :)

Your link it worked perfect like I want it to.
hmmm, I dunno.
HELP!
hahah,
Ty,
Mark

baldrn
04-13-2007, 04:00 PM
anybody have any suggestions??? about the marquee stopping before it finishes the page??
Thanks!

jscheuer1
04-13-2007, 04:42 PM
Get rid of the red part:


<p align="center"><script language="JavaScript1.2">

But, this will make the marquee off center. So, in the script add this (green):


if (iedom||document.layers){
with (document){
document.write('<table align="center" border="0" cellspacing="0" cellpadding="0"><td>')
if (iedom){
write('<div style="posit . . .

baldrn
04-13-2007, 05:42 PM
THANKS! I will try that tonite AND tone down the redness to a more burgundy..
I'm learning, I know it is a simple page but I'd rather do simple pages right and clean..thank you very much for helping me.
Enjoying the learning,
Mark

jscheuer1
04-13-2007, 06:19 PM
I didn't mean that the red color on your page was bad. I meant the red highlighted part in the code segment that I was showing you. But, now that you mention it, a gray colored border might look better.

baldrn
04-13-2007, 07:02 PM
Yea, I agree. The owner wanted a lot of red in it since he his log has red. But, actually the logo is more of a burgundy. So that'll help.

baldrn
04-14-2007, 01:18 PM
Ok, that fixed it perfectly. THANK YOU. HE didn't care, but I did.
What I'd like to do is save that exact script as a source file, like I would a jpeg, then insert it as needed. Also, if I wanted to change the marquee text, it would change ALL of the pages that used it..right?? If I changed the source jscript file?
Can anyone tell me how to save that script and use it like that? also, how do I script where its referenced to? I know where the file is, but what script do I write to reference to the source?
Thanks for helping me,
Mark

jscheuer1
04-14-2007, 01:54 PM
You can do that. Put the code without the tags (get rid of these):


<script language="JavaScript1.2">

and:


</script>

in a text file, save it as - say, marquee.js

Then use this in its place on the page and wherever else you want it to appear:


<script src="marquee.js" type="text/javascript">
/*
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
*/
</script>

Note: Just like a jpeg, if it isn't in the same directory as the page that is using it, you need to provide the path as well as the filename in the src attribute.

baldrn
04-14-2007, 09:34 PM
Very good. Learning as I am, where might I find a place to learn the attributes? As in, I don't know what attributes to script in for source.
Like, say it is in:
C:\Documents and Settings\Mark\Desktop\Website accounts

How would I script it to look there?
I do want to learn script and I need starting place.
Thanks!
Mark

mburt
04-14-2007, 09:46 PM
You kind of lost me with the folder thing, but:

Very good. Learning as I am, where might I find a place to learn the attributes?
To find the attributes of an object:

for (x in myObject) document.write(x+"\n<br>");

baldrn
04-14-2007, 09:54 PM
Sorry, my post question had 2 parts:
1-I save the new txt file and want to use it in another account. If I save the new txt. file to C:\Documents and Settings\Mark\Desktop\Website accounts,what do I type into the new page to tell it to look there for the source file? How do I point the page to that directory?
2-Where is a good place for me to learn basic javascript coding.
Thanks, and sorry for the confusion. Hope this cleared it up.
Mark

jscheuer1
04-15-2007, 08:55 AM
Well, this part has nothing to do with javascript. It is just the usage of the HTML src attribute. And:

C:\Documents and Settings\Mark\Desktop\Website accounts

Is a poor choice of places to put the script (or an image, for that matter) unless that represents the root of your live domain, if it does, then you can use:


<script src="file://localhost/C:/Documents%20and%20Settings/Mark/Desktop/Website%20accounts/marquee.js" type="text/javascript">
/*
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
*/
</script>

when testing locally. And:


<script src="/marquee.js" type="text/javascript">
/*
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
*/
</script>

for a live page. But, really - as I said - it is just like an image. Say you have an image named some.jpg in a folder named images just off of the root of your domain and your page is in a folder named pages just off of the root of the domain. Your image tag must contain a reference to its position in that folder, either relatively:


<img src="../images/some.jpg">

or in absolute terms:


<img src="/images/some.jpg">

or even (still absolute):


<img src="http://www.mydomain.com/images/some.jpg">

As for learning javascript, w3schools is decent:

http://www.w3schools.com/js/default.asp