The Little Guy Posted February 1, 2011 Share Posted February 1, 2011 I have this: var jsLive = { // some stuff item : function(){ // some more stuff } } window.jsLive = $ = window.document.$ = window.$ = jsLive; if I use this: $.item(); The code will work in Chrome/Firefox, but I get an error in IE saying "$" is undefined. What can I do to fix it? Quote Link to comment https://forums.phpfreaks.com/topic/226392-is-undefined/ Share on other sites More sharing options...
requinix Posted February 1, 2011 Share Posted February 1, 2011 Where is the jsLive stuff defined? Where is the $.item code executing from? Quote Link to comment https://forums.phpfreaks.com/topic/226392-is-undefined/#findComment-1168596 Share on other sites More sharing options...
The Little Guy Posted February 1, 2011 Author Share Posted February 1, 2011 Here one of the pages: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link rel="stylesheet" href="../style.css" /> <script type="text/javascript" src="../../live/jsLive.js"></script> </head> <body onmousemove="$.item('#pos').innerHTML = $.mouseX()+ ', '+$.mouseY();"> <div class="content"> <h1>Miscellaneous</h1> <h2>Mouse X, Y Position</h2> <div id="pos">0, 0</div> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/226392-is-undefined/#findComment-1168599 Share on other sites More sharing options...
requinix Posted February 1, 2011 Share Posted February 1, 2011 If you move the mouse on the page before jsLive.js has been loaded then you'll trigger an error. Bind to the onmousemove event only after everything's been loaded. You can add a script at the end of the page that adds the event listener rather that code it inline into the HTML. Quote Link to comment https://forums.phpfreaks.com/topic/226392-is-undefined/#findComment-1168617 Share on other sites More sharing options...
The Little Guy Posted February 2, 2011 Author Share Posted February 2, 2011 That is just an example page. I want to know how to get this to work in IE. Here are other examples that don't work in IE: <p> <a href="http://google.com" class="google" id="mylink">Google.com</a> </p> URL: <input type="text" id="url" /><br /> <input type="button" value="Change" onclick="$.item('#mylink').attr('href', $.item('#url').value);" /> <p> <input type="button" value="Load Ajax" onclick="$.query({ url :'./calls/html.html', returnTo : '#loadHTMLAjax'});" /> </p> <div id="loadHTMLAjax"> HTML returned data will display here </div> Quote Link to comment https://forums.phpfreaks.com/topic/226392-is-undefined/#findComment-1168621 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.