Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/226392-is-undefined/
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/226392-is-undefined/#findComment-1168599
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/226392-is-undefined/#findComment-1168617
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/226392-is-undefined/#findComment-1168621
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.