dcsimg
IE not evaluating object functions
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Erin_Madsen
Posted On:   Tuesday, June 19, 2007 07:50 PM

Hi, I'm working with a nice little javascript I found for scrolling text within page elements like divs, etc... and I'm running into a problem trying to execute it in, of course, Internet Explorer. You'll find the page at http://www.alternium.net/scroll/index2.html Here's the code: function TextScroll(scrollname, div_name, up_name, down_name) { this.div_name = div_name; this.name = scrollname; this.scrollCursor = 0; this.speed = 5; this.timeoutID = 0; this.div_obj = null; this.up_name = up_name; this.dn_name = down_name; { if (document.getElementById) { div_obj = document.getElementById(this.div_name);    More>>

Hi,

I'm working with a nice little javascript I found for scrolling text within page elements like divs, etc... and I'm running into a problem trying to execute it in, of course, Internet Explorer. You'll find the page at http://www.alternium.net/scroll/index2.html

Here's the code:


			
function TextScroll(scrollname, div_name, up_name, down_name)
{
this.div_name = div_name;
this.name = scrollname;
this.scrollCursor = 0;
this.speed = 5;
this.timeoutID = 0;
this.div_obj = null;
this.up_name = up_name;
this.dn_name = down_name;

{
if (document.getElementById)
{
div_obj = document.getElementById(this.div_name);
if (div_obj)
{
this.div_obj = div_obj;
this.div_obj.style.overflow = 'hidden';
}
div_up_obj = document.getElementById(this.up_name);
div_dn_obj = document.getElementById(this.dn_name);
if (div_up_obj && div_dn_obj)
{
div_up_obj.onmouseover = function() { eval(scrollname + '.scrollUp();') };
div_up_obj.onmouseout = function() { eval(scrollname + '.stopScroll();') };
div_dn_obj.onmouseover = function() { eval(scrollname + '.scrollDown();') };
div_dn_obj.onmouseout = function() { eval(scrollname + '.stopScroll();') };
}
}
}

this.stopScroll = function()
{
clearTimeout(this.timeoutID);
}

this.scrollUp = function()
{
if (this.div_obj)
{
this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
this.div_obj.scrollTop = this.scrollCursor;
this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
}
}

this.scrollDown = function()
{
if (this.div_obj)
{
this.scrollCursor += this.speed;
this.div_obj.scrollTop = this.scrollCursor;
this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
}
}

this.resetScroll = function()
{
if (this.div_obj)
{
this.div_obj.scrollTop = 0;
this.scrollCursor = 0;
}
}
}







As you can see, the four lines causing all the trouble are:


			
div_up_obj.onmouseover = function() { eval(scrollname + '.scrollUp();') };
div_up_obj.onmouseout = function() { eval(scrollname + '.stopScroll();') };
div_dn_obj.onmouseover = function() { eval(scrollname + '.scrollDown();') };
div_dn_obj.onmouseout = function() { eval(scrollname + '.stopScroll();') };


I'm not hugely experienced in overcoming IE's shortcomings, but I get around it pretty well and this one has got me stumped. If anyone's got an idea about how to get this to work, I'd love to hear it.


Also, forgive the single quotes, but I changed them from doubles thinking (hoping) that might be the issue, but it's not and I'm lazy to change something inconsequential.


Thanks.    <<Less

Re: IE not evaluating object functions

Posted By:   Erin_Madsen  
Posted On:   Tuesday, June 19, 2007 08:02 PM

Fixed!

The issue was in the HTML file which pulled the javascript. In the future, remember when you're sourcing javascript files that not many browsers understand