Do not use on any
shared computer
August 30, 2008 12:38am pdt
 
[x]
Attachment Details

'null' is null or not an object error on javascript

Zone: JavaScript
Tags: Javascript, Mootools, IE7, 'null' is null or not an object
Hi
I am getting an error in IE 7 only and it doesnt move.  It works in Firefox.

It's complaining about this line:

var myTicker = new Ticker('newsticker',{toggleButton:'toggle'});

Can anyone offer any advice on a solution please?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
I have this code in my HEAD :
 
<script type="text/javascript" src="mootools.v1.11.js"></script>
<script type="text/javascript" src="mooticker.js"></script>
  <script type="text/javascript">
    // Create ticker at domready state
    window.addEvent('domready',function() {
      var myTicker = new Ticker('newsticker',{toggleButton:'toggle'});
    });
  </script>
 
 
 
 
and this code in my BODY:
 
<div id="newsSubContainer">
  <div id="newsticker">
    <ul>
      <li>TEST 1</li>
      <li>TEST 2</li>
      <li>TEST 3</li>
      <li>TEST 4</li>
    </ul>
  </div>
  <div id="toggle"></div>
</div>
 
 
 
 
Here is the code from mooticker.js if it may help:
 
// mooticker - Newsticker class
// Original copyright 2006 Wolfgang Bartelme, Bartelme Design - http://bartelme.at
//
// Ported and edited for mootools by Huug Helmink, Ace Group bv - http://www.acegroup.nl
// version 0.2
// date 2007-09-26
//
//
// moootools v.11 classes
// Core: Core
// Class: Class, Class.Extras
// Native: Array, String, Function, Number, Element
// Element: Element.Event, Element.Filters, Element.Selectors
// Window: Window.DomReady
// Effects: Fx.Base, Fx.CSS, Fx.Style
//
//
// Usage:
// var myTicker = new Ticker('idOfDivElement');
//     or (with options)
// var myTicker = new Ticker('idOfDivElement',{toggleButton:'idOfToggleDiv',interval:####});
// with #### as an integer > 2000
//
//
var Ticker = new Class({
  // Define options
  options: {
    toggleButton: false,
    interval: 5000
  },
  
  initialize: function(containerId,options) {
    // Declare variables
    var Appear,myFade,myBlinder;
  
    // Set container div
    this.container = $(containerId);
    // Set options
    this.setOptions(options);
    this.interval = this.options.interval;
    this.toggleButton = $(this.options.toggleButton);
 
    this.messages = $(this.container).getElements('li');
    this.number_of_messages = this.messages.length;
    if (this.number_of_messages == 0) {
      this.showError();
      return false;
    }
    this.current_message = 0;
    this.previous_message = null;
 
    // Create toggle button when ID is supplied with options
    if (this.toggleButton != false) {
      this.toggle_button = new Element('a').setProperties({
        'href': 'http://www.infinitymotorcycles.com/news.asp',
        'id': 'togglenewsticker'
      }).setHTML('More...').addEvent('click',this.toggleTicker.bind(this));
   
      this.toggleButton.adopt(this.toggle_button);
    }
    
    // Display first message
    this.hideMessages();
    this.showMessage();
    // Install timer
    this.timer = this.showMessage.periodical(this.interval,this);
  },
 
  showMessage: function() {
    Appear = new Fx.Style(this.messages[this.current_message],'opacity',{onStart:function(item) {
      item.setStyle('display','block');
    }}).start(0,1);
    this.fadeMessage.delay(this.interval-2000,this);
    if (this.current_message < this.number_of_messages-1) {
      this.previous_message = this.current_message++;
    } else {
      this.current_message  = 0;
      this.previous_message = this.number_of_messages - 1;
    }
  },
 
  fadeMessage: function() {
    myFade = new Fx.Style(this.messages[this.previous_message],'opacity',{onComplete:function(item) {
      item.setStyle('display','none');
    }}).start(1,0);
  },
 
  hideMessages: function() { 
    this.messages.each(function(message) { 
      message.setStyles({
        'display': 'none',
        'opacity': 0
      });
    })
  },
 
  toggleTicker: function() {
    myBlinder = new Fx.Slide(this.container,{duration:1000});
  },
 
  // Display error message when there is no list, or the list is empty
  showError: function() {
    if ($ES('ul',this.container).length == 0) {
      this.list = new Element('ul');
      this.container.adopt(this.list);
    } else {
      this.list = $E('ul',this.container);
    }
    this.errorMessage = new Element('li',{
      'class': 'error'
    }).setHTML('Could not retrieve data');
    this.list.adopt(this.errorMessage);
  }
});
Ticker.implement(new Options);
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Programming
Question Asked By: tingleweb
Solution Provided By: cwichoski
Participating Experts: 1
Solution Grade: A
Views: 289
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by cwichoski
Expert Comment by cwichoski:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by tingleweb
Author Comment by tingleweb:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by cwichoski
Expert Comment by cwichoski:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by tingleweb
Author Comment by tingleweb:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by cwichoski
Expert Comment by cwichoski:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by tingleweb
Author Comment by tingleweb:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by cwichoski
Accepted Solution by cwichoski:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by tingleweb
Author Comment by tingleweb:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Assisted Solution by cwichoski
Assisted Solution by cwichoski:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628