function hit_test(evt)
{
if (!evt) evt = window.event;
if (evt) document.getElementById("a").innerHTML = evt.clientX;
}
</script >
which works nicely;
I understand that the 'event' object is a globally accessible object in IE but not in Mozilla; instead in Mozilla the 'event' object is sent, by default, as the first parameter in a call to a function; is this true? ...
For some odd reason, event.clientX and event.clientY don't work in safari in mac os x leopard. They used to, but it appears it cannot find the object "event".
[URL]
In the file windowsxp.js (don't get confused with windowsxp.jos), the movecursor() function moves the cursor div. It works, but the event.clientX issue seems to be messing the entire function up. Why is this happening? Anything in my page that is messing it up?
(notice: the url I've given will open a "launcher" webapp, and you must click on "windowsxp.jos" to load external files and see the problem) TypeError: Result of expression 'event' [undefined] is not an object.
I'm trying to use the window.event.clientX value for positioning a javascript routine, but I'm having trouble. When the javascript routine comes up, it comes up in a certain position based on window.event.clientX. However, the user could click on something in the script display (say, like a menu, or a calendar, or something), that my "refresh" (reload that same script but with different values). Thus, the first time, it works perfectly, but thereafter, it sets the new x,y values to the most recent window.event.clientX and window.event.clientY positions. I want it ONLY USE the positions which were first used.
Does this make sense? Ok, here is the code snippets:
// This is the javascript function RollOver( Text ) { HelpText = Text ; HelpX = window.event.clientX; HelpY = window.event.clientY; ToShow = setTimeout( "DoRollOver()", 1, "JAVASCRIPT" );}
// This is the HTML <input type="Text" name="timestamp1" value=""> <img src="myImage.gif" onmousedown="RollOver( getText() );">
The first time the image is clicked, the source comes up in the correct place. But this new script that came up is now the current "event" so when someone clicks on something to reload the script with a different value, it sets the position relative to the lastest script placement, not the original image.
how can I detect if mouse cursor is over or out of some element? I am running a animation, which I don't want to run or to stop itself if cursor gets to area.
I want each instance of an object to be able to listen for input events. When the event occurs, a method of the object should be called, such that "this" is in scope and refers to the object instance.
Is this possible? Example:
function MyConstructor(element) { //element is some HTML element this.addListeners(element);
I have a JS method register in a TD element as below:
Below is the Js Method:
The JS method works fine in IE but in mozilla throws an error that event is undefined.
I cant pass the event object from HTML while registering the method as HTML is written by someone else and I cannot change that. All I can change is the JS method.
I can't set onclick event properly for OBJECT (flash) element properly. onclick just don't bubble outside flash object. Could this be caused by AS getUrl() function?
I tried to attach thru .htc, tried transparent IFRAME on top of object, etc. Nothing seems to work.
Is there any reasonable way to attach onclick to OBJECT element or flash movie by using JS or plain HTML? Should I do something for event bubbling?
If I have several links with onClick events pointing to the same function, how can I get a reference back to the link that was clicked? I'd like to change the link text after the onClick fires so the user knows something is happening, without having to create and assign id's to every link.
I'm trying to build a Validation object, where you pass an object id and event name in the constructor. Then, you call an add_rule method to add validation rules. The constructor code looks something like:
function Validation(id, event, ...) { this.object = document.all[id]; this.event = event; var obj = this.object; obj[event] = this.validate; }
So the actual validation function is dynamically bound to the appropriate event. The problem is that when the validate method is called, "this" no longer refers to the Validation object; it refers to the object to whose event it was bound. So, for instance, in the following code, the validate function's "this" refers to frmSubmit, not objValidate:
objValidate = new Validation ("frmSubmit", "onsubmit", ...);
Of course, I need to refer to the actual validation object's properties, but I can't figure out how. Any suggestions?
i am trying to load/embed pdf inside a html object tag. since loadng of pdf content takes time, I want to capture onload complete event of object tag and take some action/msg to show usr that loading is complete. but i am not able to capture onload event of object tag. i get pdf content from an aspx page in bytestream and set it as data in object tag:
JS: function loadObjectsuccess() { alert('pdf has loaded now');
If a function with multipe parameters has an event object as one parameter then how do we pass an event argument to that function without using inline function calling?
For example:
Code:
function key_pressed(ev,msg){ var keycode; if (window.event){ ev = window.event;
THE QUESTION: How do I get a reference to my Object when processing an event handler bound to an html element ?
CONTEXT: Sorry if it is a bit long.
I am developing a JS calendar tool. One of the requirements is that the calendar will need to display a varying number of months (1..3) depending on the calling page. Imagine 1, 2 or 3 calendar pages side by side as required.
I have built a grid object that will contain one month's dates with the day names at the top. The calendar object inherits the grid object as an array of "calendar pages" - one grid per month and the calendar provides the content for each grid. I will use the grid object for another completely different object later and so I want to use good OOP encapsulation. The grid is a table generated on the fly and is "dumb" as far as what it is used for.
I have attached an onlick event to each cell of the grid. Using OOP priciples I want the calling program (the calendar object in this case) to provide a function to handle the click and the grid object will provide to the calendar the row and column of that cell as well as the grid number (so the calendar can work out which date was clicked since it knows what the data means and the grid doesnt). Code:
Trying to figure out what was happening in a snippet in the jQuery docs. The snippet I refer to is here , documenting event objects.
The code:
Has me a tad confused. I know that e is an event object that calls keydown event for keycode 64 but what I am unsure of is how it is being triggered. There is no context to it, if you use .trigger() that way is the event called upon the loading of the object? If not when is .trigger() being called?
i'm from germany and i'm new to jQuery so i hope i can explain my problem in a right way...
I'm reading some data from a xml file with ajax and i'm creating a list of this data pieces. Now i want to do something whenever you click on an item of that list.I think i'll just show you some of my code:
[Code]...
At first i create a list with id="liste" and add list items from the xml file to it. Then i want the script to call function getInfos() when you click on an item. But it does not work like this.
I've been playing around with JS for a while, but I've not ever found fantastic learning resources. I'm comfortable with other programming languages, so I'm very interested in OOP programming for JS, and I've started to use tools like the Prototype library for that purpose.
However, one problem has consistently caused me problems whenever I'm writing a JS Class. How can I get a reference to the specific class instance from inside an event handler that I create with a class method. Let me give an example of what I want to do:
(This code is using the Prototype library...)
myClass = Class.create(); myClass.prototype = { makeLink: function(obj) { // Out here, "this" refers to the instance of the myClass Class obj.innerHTML = '' obj.onclick = function() { // In here, "this" refers to the clicked on element. // How do I get a reference to the instance of myClass in here? } }
Here's the best way that I know how to do this right now. It seems to work in Firefox alright, but doesn't seem to work in IE:
myClass = Class.create(); myClass.prototype = { makeLink: function(obj) { obj.innerHTML = '' self = this; // Save a reference to class instance as "self" obj.onclick = function() { // Self is evaluated to instance reference at time of assignment to onclick self.linkClicked(); }
linkClicked: function() { // Do something useful here }
}
Is there a more elegant way to do this? I could just create all of my event handlers for objects outside of the class in procedural code where I already have a reference to the class object, but I like to wrap these things up inside the class, because sometimes they get significantly more complicated than this very simple one. Anybody have any solutions? This has to be a common design pattern...
Probably covering well trodden ground here but so far I haven't found any reliable solution and "it can't be done" seems crazy. Here goes:I have some Flash and non-flash banners that are to be embedded into my page - all managed by a simple CMS. The Flash movies are not created by me as they are for 3rd Party advertisors, and I do not want to be doing any Flash programming myself as it's not my thing and I don't have the resource to do it. As with the JPEG/GIF files - I just want to be given the file and then embed it.
What I want to do is produce some MI based upon when the various banners are clicked - things like how many clicks and who clicked them (users are logged into the web site so I can track them). Simple enough for JPEG/GIF banners capturing the onclick event but for Flash it seems that the Flash movie prevents (or overrides) the onclick event from registering.This seems crazy! I want my application logic (in this case logging user activity) to be independant of the media content - especially as I am not in control of the media content.Googling and experimentation shows that for IE I can seemingly use "onfocus" but this is not very satisfactory and of course I need a cross browser solution.This seems like such a simple concept that at the time of specifying the requirements it didn't occur to me that this might not be possible.... but it seems that I may be wrong!
This object was passed to my click event handler. Why are so many properties missing? The click event came from an <a> in a <li>, propagated down to the <ul> on which the handler was set.
If I click on the <ul>, the event object looks "normal".
I got this problem with live() event.I have used it as follows.
$(".addressDiv span").live("mouseover", function(){ //clickable function here...... ------------------------ });
I have used the live() event to trigger the function on mouseover in the dynamically added elements. But the problem i got is that once the live event is called it takes the class of the element and stores. And when the class of that particular element is changed dynamically the live() event does not detect the new classed added dynamically, instead it takes the former class. Live() event does not update the class.