PDA

View Full Version : Memory Scroller Help



dresdek
05-12-2006, 04:17 AM
hey, I am having trouble using the memory scroller script (http://www.dynamicdrive.com/dynamicindex2/memoryscroller.htm), It is exactly the type of scroller I am looking for but I am new to javascript and was wondering how you could include an external file as the message's content, such as php or html, instead of typing in a message of the text to be scrolled which occurs here:

var memorycontent='<nobr><span style="font: bold 13px Verdana">Thank you for visiting <a href="http://www.dynamicdrive.com">Dynamic Drive.</a> If you find this script useful, please consider <a href="http://www.dynamicdrive.com/link.htm">linking to</a> or <a href="http://www.dynamicdrive.com/recommendit/">recommending</a> Dynamic Drive.</span></nobr>'

the file is formatted such that it only shows up on one line. Appreciate any help you can give me.

ddadmin
05-12-2006, 06:25 AM
The easiest way in this case, though not the most versatile, would just be to save your scroller contents inside an external .js file that appears above the memory scroller code itself. So inside something like "contents.js", you'd have:


var memorycontent='<nobr><span style="font: bold 13px Verdana">Thank you for visiting <a href="http://www.dynamicdrive.com">Dynamic Drive.</a> If you find this script useful, please consider <a href="http://www.dynamicdrive.com/link.htm">linking to</a> or <a href="http://www.dynamicdrive.com/recommendit/">recommending</a> Dynamic Drive.</span></nobr>'

Then on your page, it'd be referenced as:


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

<script...>
rest of memory scroller minus "memorycontent" variable here...
</script>

dresdek
05-12-2006, 07:16 AM
I see what you're saying and that would work if I knew how to write the results of a php file to a javascript file because the file contents are constantly changing.

I found another solution however that would work, if i could only find any other way to just rewrite the var memorycontent expression without the use of apostrophes. The content of the file is article titles and many of them have apostrophes, and i have cms that imports these titles directly into the code through a replacement tag, but then the code gets very confused.
But I'm not sure how to rewrite this as i'm a newbie to javascript.

So is there anyway to rewrite this var memorycontent expression without the use of any single apostrophes? :D