Jump to content

Rolling Text Box Question


AnitaB

Recommended Posts

I am trying to create a rolling text box and am having some difficulty. The box shows up but the text is not rolling. Can anyone help? The code I used is as follows:

 

The HTML code:

 

Text for scrolling box here.

initSlidingContent('scrollingContainer',3);

 

 

The CSS code:

 

#scrollingContainer{

width:120px;

height:160px;

background-color: #E2EBED;

float:left;

margin-right:10px;

font-size:0.9em;

}

 

Thanks!

Anita

Link to comment
Share on other sites

Sorry, here is that code which I placed in my index.html file after the above html code: (now that's everything I have for the rolling text box)

 

var slideTimeBetweenSteps = 30; // General speed variable (Lower = slower)

 

 

var scrollingContainer = false;

var scrollingContent = false;

var containerHeight;

var contentHeight;

 

var contentObjects = new Array();

var originalslideSpeed = false;

 

function slideContent(containerId)

{

var topPos = contentObjects[containerId]['objRef'].style.top.replace(/[^\-0-9]/g,'');

topPos = topPos - contentObjects[containerId]['slideSpeed'];

if(topPos/1 + contentObjects[containerId]['contentHeight']/1<0)topPos = contentObjects[containerId]['containerHeight'];

contentObjects[containerId]['objRef'].style.top = topPos + 'px';

setTimeout('slideContent("' + containerId + '")',slideTimeBetweenSteps);

 

}

 

function stopSliding()

{

var containerId = this.id;

contentObjects[containerId]['slideSpeed'] = 0;

}

 

function restartSliding()

{

var containerId = this.id;

contentObjects[containerId]['slideSpeed'] = contentObjects[containerId]['originalSpeed'];

 

}

function initSlidingContent(containerId,slideSpeed)

{

scrollingContainer = document.getElementById(containerId);

scrollingContent = scrollingContainer.getElementsByTagName('DIV')[0];

 

scrollingContainer.style.position = 'relative';

scrollingContainer.style.overflow = 'auto';

scrollingContent.style.position = 'relative';

 

scrollingContainer.onmouseover = stopSliding;

scrollingContainer.onmouseout = restartSliding;

 

originalslideSpeed = slideSpeed;

 

scrollingContent.style.top = '0px';

 

contentObjects[containerId] = new Array();

contentObjects[containerId]['objRef'] = scrollingContent;

contentObjects[containerId]['contentHeight'] = scrollingContent.offsetHeight;

contentObjects[containerId]['containerHeight'] = scrollingContainer.clientHeight;

contentObjects[containerId]['slideSpeed'] = slideSpeed;

contentObjects[containerId]['originalSpeed'] = slideSpeed;

 

slideContent(containerId);

 

}

 

Link to comment
Share on other sites

Thanks!! It's working! However, the only line that is not validating is:

 

if(topPos/1 + contentObjects[containerId]['contentHeight']/1<0)topPos = contentObjects[containerId]['containerHeight'];

 

with the "<" highlighted and the following error message:

 

This message may appear in several cases:

 

You tried to include the "<" character in your page: you should escape it as "<"

You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe.

Another possibility is that you forgot to close quotes in a previous tag.

 

Do you know why that might be the case?

 

Thanks again!

Anita

Edited by AnitaB
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...