dom - JavaScript "null or not an object" error -


i'm running javascript below place horizontal scrolling text on banner of website. works in 1 server not another. following error:

error: 'this.mqo' null or not object

javascript:

function start() {     new mq('m1'); /* new mq('m2');     */     mqrotate(mqr); // must come last } window.onload = start;  // continuous text marquee // permission use javascript on web page granted // provided of code below in script (including these // comments) used without alteration  function objwidth(obj) {     if (obj.offsetwidth) return obj.offsetwidth;     if (obj.clip) return obj.clip.width;     return 0; } var mqr = [];  function mq(id) {     this.mqo = document.getelementbyid(id);     var wid = objwidth(this.mqo.getelementsbytagname('span')[0]) + 5;     var fulwid = objwidth(this.mqo);     var txt = this.mqo.getelementsbytagname('span')[0].innerhtml;     this.mqo.innerhtml = '';     var heit = this.mqo.style.height;     this.mqo.onmouseout = function () {         mqrotate(mqr);     };     this.mqo.onmouseover = function () {         cleartimeout(mqr[0].to);     };     this.mqo.ary = [];     var maxw = math.ceil(fulwid / wid) + 1;     (var = 0; < maxw; i++) {         this.mqo.ary[i] = document.createelement('div');         this.mqo.ary[i].innerhtml = txt;         this.mqo.ary[i].style.position = 'absolute';         this.mqo.ary[i].style.left = (wid * i) + 'px';         this.mqo.ary[i].style.width = wid + 'px';         this.mqo.ary[i].style.height = heit;         this.mqo.appendchild(this.mqo.ary[i]);     }     mqr.push(this.mqo); } function mqrotate(mqr) {     if (!mqr) return;     (var j = mqr.length - 1; j > -1; j--) {         maxa = mqr[j].ary.length;         (var = 0; < maxa; i++) {             var x = mqr[j].ary[i].style;             x.left = (parseint(x.left, 10) - 1) + 'px';         }         var y = mqr[j].ary[0].style;         if (parseint(y.left, 10) + parseint(y.width, 10) < 0) {             var z = mqr[j].ary.shift();             z.style.left = (parseint(z.style.left) + parseint(z.style.width) * maxa) + 'px';             mqr[j].ary.push(z);         }     }     mqr[0].to = settimeout('mqrotate(mqr)', 10); } 

the reason there no element id "m1". place line first in start function diagnose this:

alert(document.getelementbyid('m1')); 

if shows "[object]" (or similar), element exists , it's other problem, if shows "undefined" means there no such element in page.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -