Cross browser scroller - contents from external text file

I need to find or create a cross browser scroller where the contents scroll from right to left. The contents of the scroll message will need to come from an external file.

I am putting this into an ASP page.

Help?
edrz01Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ddrudikCommented:
This will require an integration of both ASP and JS, first for ASP server-side to read the text file:
<%
Dim oFSO, oFS, sText
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFS = oFSO.OpenTextFile(Server.MapPath("yourfile.txt"),1,false)
sText = oFS.readall
oFS.Close
set oFS = nothing
set oFSO = nothing
%>

You would put that code at the top of a new .asp file you create, with the following's solution HTML code below that:
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_21310994.html

Finally, replace:
<span id="divText">
<nobr>crusin'... on a Sunday afternoon...to
<a id="link" href="http://experts-exchange.com/">Experts-Exchange</a>
</nobr></span>

With:
<span id="divText"><%=sText%></span>

And when you view the .asp page in a browser the text file will be read by ASP and displayed in the span to be scrolled by Javascript.
0
edrz01Author Commented:
ddrudik

Sorry it took me so long to get back - crazy week!

I attempted to make the changes you suggested but guess I missed something. I "assumed" you wanted me to merge your suggestions with the other EE tip. This is what I came up with - it didn't work.

Can you check it and see where I errored?

<html>
<%
Dim oFSO, oFS, sText
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFS = oFSO.OpenTextFile(Server.MapPath("f:\test.txt"),1,false)
sText = oFS.readall
oFS.Close
set oFS = nothing
set oFSO = nothing
%>
<head>
<style type="text/css">
#scroller {
  overflow: hidden;
  border: 1px solid black;
  width: 250px;
  height: 1.25em;
}
</style>
<script type="text/javascript">
window.onload = init;

function init()
{
  obj = document.getElementById("message");

  // get width of message
  var clone = obj.cloneNode(true);
  document.body.appendChild(clone);
  totalWidth = clone.offsetWidth;
  document.body.removeChild(clone);

  // get width of scroller
  start = document.getElementById("scroller").offsetWidth;

  // start message on right-hand side of scroller
  horizPos = start;

  setInterval("scroll();", 25);
}

function scroll()
{
  horizPos = (horizPos == -1 * (totalWidth -1)) ? start: (horizPos - 1) % totalWidth;
  obj.style.marginLeft = horizPos + "px";

}
</script>
</head>

<body>
<div id="scroller">
<span id="divText"><%=sText%></span>
</div>
</body>
</html>
0
ddrudikCommented:
See the manual page on Server.MapPath:
http://msdn2.microsoft.com/en-us/library/ms524632.aspx
Server.MapPath is useful for referencing a file relative to the current script location, and if f:\ is a network drive you will likely not be too successful in your attempts to access with ASP due to permissions issues.

Copy test.txt to the same directory as the ASP script and then use:
<html>
<%
Dim oFSO, oFS, sText
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFS = oFSO.OpenTextFile(Server.MapPath(".") & "\test.txt" ,1)
sText = oFS.readall
oFS.Close
set oFS = nothing
set oFSO = nothing
%>
<head>
<style type="text/css">
#scroller {
  overflow: hidden;
  border: 1px solid black;
  width: 250px;
  height: 1.25em;
}
</style>
<script type="text/javascript">
window.onload = init;
 
function init()
{
  obj = document.getElementById("message");
 
  // get width of message
  var clone = obj.cloneNode(true);
  document.body.appendChild(clone);
  totalWidth = clone.offsetWidth;
  document.body.removeChild(clone);
 
  // get width of scroller
  start = document.getElementById("scroller").offsetWidth;
 
  // start message on right-hand side of scroller
  horizPos = start;
 
  setInterval("scroll();", 25);
}
 
function scroll()
{
  horizPos = (horizPos == -1 * (totalWidth -1)) ? start: (horizPos - 1) % totalWidth;
  obj.style.marginLeft = horizPos + "px";
 
}
</script>
</head>
 
<body>
<div id="scroller">
<span id="message"><%=sText%></span>
</div>
</body>
</html>

Open in new window

0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

edrz01Author Commented:
When I try this code in my masterpage I get the following error:

Pasted"

<%
Dim oFSO, oFS, sText
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFS = oFSO.OpenTextFile(Server.MapPath(".") & "\test.txt" ,1)
sText = oFS.readall
oFS.Close
set oFS = nothing
set oFSO = nothing
%>




Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS1044: Cannot use more than one type in a for, using, fixed, or declaration statement

Source Error:

 

Line 70: <%
Line 71: Dim oFSO, oFS, sText
Line 72: Set oFSO = CreateObject("Scripting.FileSystemObject")
Line 73: Set oFS = oFSO.OpenTextFile(Server.MapPath(".") & "\test.txt" ,1)
Line 74: sText = oFS.readall
 

Source File: c:\Inetpub\SolarWinds\Orion\MasterPage.master    Line: 72
0
ddrudikCommented:
That code is valid ASP by itself, are you declaring oFSO or oFS earlier in the script?
<%
Dim xoFSO, xoFS, sText
Set xoFSO = CreateObject("Scripting.FileSystemObject")
Set xoFS = xoFSO.OpenTextFile(Server.MapPath(".") & "\test.txt" ,1)
sText = xoFS.readall
xoFS.Close
set xoFS = nothing
set xoFSO = nothing
%>
0
edrz01Author Commented:
Ok, I think I see the problem. This is being inserted into another app's asp master page which uses C#. I see it is decalred at the top by <%@ Master Language="C#" AutoEventWireup="true" %>

I tried to go to a free vb to c# conversion site but it still didn't work.
0
ddrudikCommented:
Can't help there, just providing a solution from an ASP perspective.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
edrz01Author Commented:
Thanks for the assist. Even though the solution didn't work you pointed me in the right direction.
0
ddrudikCommented:
Thanks for the question and the points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.