ionezation Posted March 5, 2014 Share Posted March 5, 2014 These scripts are not working .. I`ve crossed check them from Source code also. Please check. Utilities.js var U = { $: function(id){ 'use strict'; if(typeof id == 'string'){ return document.getElementById(id); } // inner IF }, // $() function setText: function (id,message){ 'use strict'; if((typeof id == 'string') && (typeof message == 'string')){ var output = this.$(id); if (!output)return false; if(output.textContent !== undefined){ output.textContent = message; }// second inner IF else { output.innerText = message;} return true; }// inner IF },// SetText Function addEvent : function(obj,type,fn){ 'use strict'; if(obj && obj.addEventListener){ obj.addEventListener(type,fn,false); }//inner IF else if (obj && obj.attachEvent){ obj.attachEvent('on' + type, fn); }// Else IF },// addEvent Property removeEvent : function(obj,type,fn){ 'use strict'; if(obj && obj.removeEventListener){ obj.removeEventListener(type,fn,false); }// inner IF else if(obj && obj.detachEvent){ obj.detachEvent('on' + type, fn); }// Else IF }// RemoveEvent }; Epoch.js function updateDuration(){ 'use strict'; var now = new Date(); var message = 'It has been ' + now.getDate(); message += ' seconds since epoch.(Mouseover to Update)'; U.setText('output', message); }// Update Duration Function Ends Here window.onload = function(){ 'use strict'; U.addEvent(U.$('output'), 'mouseover', updateDuration); updateDuration(); }; // Onload Function Epoch.html <!doctype html> <html> <head> <meta charset="utf-8"> <title>Mouse Events - Javascript</title> </head> <body> <div id="output"></div> <script src="utility.js"></script> <script src="epoch.js"></script> </body> </html> Link to comment Share on other sites More sharing options...
Larry Posted March 7, 2014 Share Posted March 7, 2014 How are they not working? What is happening that shouldn't? What isn't happening that should? In what browser(s) have you tested this? You need to provide many more details here. Link to comment Share on other sites More sharing options...
HartleySan Posted March 7, 2014 Share Posted March 7, 2014 What are the console errors being logged? Link to comment Share on other sites More sharing options...
Recommended Posts