Any Good Examples Of Usage Of Document.elementfrompoint ?
Jul 23, 2005
What is meant by "element"?
When mouse is moved over "element" at x,y, is that "element" the entire
image or something else?
My thought would be to simply retrieve the thumbnail name or other ID and
use that to identify which large image to show.
Any reasons why NOT to use this property?
View 2 Replies
ADVERTISEMENT
May 10, 2009
Are there any good web UI component libraries -open source or commercial - that you can recomment? They need to be cross browser compatible and have good documentation. Jquery UI is very good but limited in number of controls it offers. YUI is very verbose and very hard to use. extJs only other one I can think of. Any others you use and like?
View 2 Replies
View Related
Jun 16, 2003
I recently had need for the method document.elementFromPoint() found in Internet Explorer (http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/elementfrompoint.asp).
My immediate method for implementing this was artificially creating an arbitrary mouse event (decided on mousemove) at the specified coordinates, setting up an event listener on the document, firing the event, record the target, and remove the listener.
However, I apparently didn't pay close enough attention to this (http://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget-dispatchEvent):
The target of the event is the EventTarget on which dispatchEvent is called.
However, I had a hunch that Mozilla was merely redirecting the event to the document to be correct, and actually stored somewhere the "correct" target. After dumping the event object, I found a property which must have been recently introduced (Mozilla 1.4 branch apparently) called "explicitOriginalTarget" which is like originalTarget, but apparently never targets anonymous content, and in this case, also differs by referring to the element where the coordinates of the mouse event were.
Anyhoo, here's some code. I've tested it in various Mozilla 1.4 builds successfully (and double checked explicitOriginalTarget in < 1.4 builds to find that it doesn't exist). Firebird 0.6 is also based on 1.4, so it works in that too. By using the browser's box object and mouse events, instead of hacking my own, I don't think there should be any issues with it picking up elements that can't be seen.
// Program: document.elementFromPoint(int clientX, int clientY) in Gecko
// Author: Jason Karl Davis (www.jasonkarldavis.com)
// Date: 15 June 2003
// Purpose: Emulate Internet Explorer's document.elementFromPoint method as described here:
// http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/elementfrompoint.asp
// Requirements: A browser built off of the 1.4 branch of Mozilla (or better)
// Distribution: You may freely distribute and use this script as long as these comments remain intact
if (navigator.product == "Gecko") {
Document.prototype.elementFromPoint = function(x, y) {
this.addEventListener("mousemove", this.elementFromPoint__handler, false);
var event = this.createEvent("MouseEvents");
var box = this.getBoxObjectFor(this.documentElement);
var screenDelta = { x: box.screenX, y: box.screenY };
event.initMouseEvent("mousemove", true, false, this.defaultView, 0,
x + screenDelta.x, y + screenDelta.y, x, y,
false, false, false, false, 0, null);
this.dispatchEvent(event);
this.removeEventListener("mousemove", this.elementFromPoint__handler, false);
return this.elementFromPoint__target;
}
Document.prototype.elementFromPoint__handler = function (event) {
this.elementFromPoint__target = event.explicitOriginalTarget;
// reparent target if it is a text node to emulate IE's behavior
if (this.elementFromPoint__target.nodeType == Node.TEXT_NODE)
this.elementFromPoint__target = this.elementFromPoint__target.parentNode;
// change an HTML target to a BODY target to emulate IE's behavior (if we are in an HTML document)
if (this.elementFromPoint__target.nodeName.toUpperCase() == "HTML" && this.documentElement.nodeName.toUpperCase() == "HTML")
this.elementFromPoint__target = this.getElementsByTagName("BODY").item(0);
event.preventDefault();
event.stopPropagation();
}
Document.prototype.elementFromPoint__target = null;
}
And the reason I prototyped Document instead of adding it to document directly is that any extra documents you may have loaded on the same page inherit those methods. For example, an iframe or something. And it /should/ be usable in other, non-HTML documents as well, such as MathML, SVG, XUL, etc. :)
View 5 Replies
View Related
May 6, 2011
I need create a function that queries a link or an input text according to the x,y location using ementFromPoint(x,y).As as result I need to know:- Type.- URL.- Text.- Tittle.I have been trying to do this with elem.innerHTML however I get a lot of information and not what I need.
View 1 Replies
View Related
Oct 23, 2005
Where can I find some examples about javascript and the use of layers?
View 1 Replies
View Related
Dec 8, 2011
I'm looking for simple examples of JavaScript for the following table>
View 3 Replies
View Related
Jul 18, 2006
I'm looking for a library of practical JavaScript examples.
View 7 Replies
View Related
Apr 30, 2009
I'm trying to get tablesorter [URL] working but pasting the example table, when the given document.ready() function fires, I get a javascript error saying that $ ("myTable").tablesorter(); is not a function. Can anyone confirm this works with Jquery 1.2.3?
View 1 Replies
View Related
May 31, 2011
6. Display a message saying Good Morning if it is in the morning, Good Afternoon if it is in the afternoon, and Good Evening if it is in the Evening. This is my code:
[Code]....
View 1 Replies
View Related
Jul 23, 2005
The question has to do with the use of popup
windows in a web page. I have heard that popup
windows should be avoided; due to use of popup
blockers and browser that do not process javascript.
Is the use of popup windows bad design?
Will it severly reduce the usage of our web page?
Note, The popup windows are created using only
onClick events, not onLoad or onClose events.
Do popup blockers make any distinction between
the two?
View 3 Replies
View Related
Jul 23, 2005
Can someone help my syntax?
var z=myForm.myInputTag.value.string().replace(" ","-");
I would expect the above to allow z to take the value of an input tag
(called myInputTag) and replace spaces with dashes...
It doesn't change the string - nor do I get errors in the Mozilla
javascript console...
View 4 Replies
View Related
Jul 20, 2005
I'm really hoping someone out there can help me with an unusual,
frustrating XP problem that I just can't seem to fix.
When certain web pages are opened with my Internet Explorer 6, it
causes the CPU to jump up to 100% usage, and my computer comes to
almost a halt. The culprit, according to Task Manager, is always
IEXPLORE.EXE, or at least one of the IEXPLORE.EXEs if there are
multiple instances.
I've noticed a common thread to virtually all sites that cause the
CPU to run at 100% -- Javascript. Pages containing Javascript are
virtually always the problem. Examples:
1) almost all pop up windows
2) Yahoo! Mail
3) Match.com Searches
4) All Music Guide
I'm not a computer expert at all, so I've only done what I can think
of, or what has been suggested to me. I've checked/removed
spyware/malware with multiple pieces of software (Spybot, etc.) I've
defragged. I've checked for viruses using both NAV and PC-cillin.
I've used my System Mechanic program to go through almost all
fixes/maintanance/optimizers. The only thing i haven't been able to
do is Windows ChkDisk, because it gets stuck every time I try to use
it.
View 1 Replies
View Related
Jul 20, 2005
I'm used to C/C++ where if you "new" something you really need to "delete"
it later. Is that also true in javascript? if i do "mydate = new date();"
in a function and dont "delete mydate" when the function exits do i have a
memory leak or other trouble brewing?
ie:
function MyFn() {
var mydate;
mydate = new date();
}
does the above function present a problem (what if its called over and over
and over etc)? or is the allocation automaticaly freed on function exit?
View 2 Replies
View Related
Jul 4, 2009
I'm writing a very complex javascript application and I'd like memory usage to be as low as possible, so I've got a question about objects.
I'm using jQuery and my code is a bunch of jQuery plugins that interact with eachother. Will there be a difference in memory usage if I declare functions like this:
I haven't written anything in javascript as complex as I'm about to write, so I never worked with objects. As far as I understand, $.fn.whatever will add function to prototype, while $.whatever will add function only to one entry of jQuery object.
So question comes down to this: when jQuery object is being created, are functions in it being copied (meaning increase in memory usage) or does javascript only make references (meaning no significant increase in memory usage) to one main entry of that function in prototype?
View 3 Replies
View Related
Jan 27, 2011
I noticed that Apple updated their website. In this thread I asked what people's thoughts on it were, but one of the main things I noticed in the mac and or the iPod pages is that the content elegantly spreads outward form the centre and fades in when the document is loaded.
So, I have a few questions, How would one do this? I know the fading can be done with jQuery, but what about the fanning-out form the centre? And also how the fade order is from top to bottom not what loads first is one of the aspects that makes it elegant, I believe. How would one do this?
View 1 Replies
View Related
Mar 17, 2011
My original fiddle for a solution used a separate callback function which just called def.resolve().However I then remembered that I've seen other code simply pass "def.resolve" as a callback in its own right. I tried this instead, and it works (see http://jsfiddle.net/Nyg4y/3/).This got me wondering - how does this work? As I understand it for this to work at all the value 'def.resolve' must be specific to 'def'.This suggests that it is actually a (reference to a) closure holding a reference to 'def' in its scope. Is my understanding correct, and if so is this behaviour guaranteed?
View 2 Replies
View Related
Apr 13, 2010
I have a simple page and a javascript that measure the time the user has spent on a page and I want that variable to pass as a link to another page (php). I'm stuck (rookie) with how to actually pass that on in the link.Here's my code:
<?php session_start();?>
<html>
<head>
[code]....
View 2 Replies
View Related
Jan 16, 2009
I am using this code load a file from server to display in to a div.
Code JavaScript:
function getHTTPObject() {
var xhr = false;
if (window.XMLHttpRequest) {
xhr = new XMLHttpRequest();
[Code]...
I want to use the same script but apply for a button, clicking the button, a file called from server will display in the div "ask_seller". Since button has no href attribute, I don't know how to name the file that going to be called(or I don't know what is the usage in this case)
View 4 Replies
View Related
Feb 4, 2010
I am fairly new to javascript but I am an experienced php programmer. I have been parsing XML information using php, but my CPU usage has been too high recently due to this. I am trying to convert my scripts to javascript, but I am unsure how I can do this using javascript. I think that if I get started off, the rest will be easy.
One of my XML files is located at
Code:
http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=bbcradio1&api_key=c910b0bc1e2d4e64964ebcd2d69c255c&limit=500
Basically I have been trying to grab the Name, Artist and large image of the most recent <track>.
View 3 Replies
View Related
Aug 23, 2011
I have a really long application so i'm trying to minimiza cpu/memory usage,with each function, therefore I have a few simple questions.
1. on elements added after the page has been loaded,is there a difference between putting "onclick" inside the element tag or using jquery's delegate like the following example?
$("#mainchatwindow").delegate('img[func="gift"]','click' function....
2. does it make a big difference selecting an element with a full path like (#body #contentdiv #userstbl td.example)or just typing (.example) ?
3. I have 2 arrays of objects, both objects has an id attribute, one of then objects are the images on the page, the second one is an ajax result with updated images.will it be better to first loop threw both objects just to create new arrays with just the id's instead of looping the threw those big objects? like this:
Code:
if (data.online)
var online_length = data.online.length;
else[code]..........
View 1 Replies
View Related
Jul 7, 2011
Working with two URLs:
Working: [url]
Trying to get to work: [url]
Issue: Received project from previous developer who left. The working URL generates a table chart using Javascript after you have entered a valid address/zip code. I haven't been able to determine why I can't get the "schoolfinder-business.asp" URL to generate a table chart using Javascript. I believe the issue is related to something in the function GetDirections, but I cannot pinpoint the issue.
View 1 Replies
View Related
Oct 15, 2010
Where can I get javascript documentation for offline usage?
View 1 Replies
View Related
Mar 3, 2010
Am using the jQuery datepicker and am having a heck of a time setting the date in it.I declare my datepicker with:
Code:
$('#datepicker').datepicker({
inline: true,
[code].....
View 1 Replies
View Related
Jan 13, 2012
Is there a way to check the page for invalid usage (e.g. text boxes using .text which doesnt exist)? I originally thought I could use the .data("events") but then realize that .text and .val isn't an event which is pretty obvious but I'm stuck now. I already know my selector is $('input[type="text"]') but is there any way to see if anywhere on the page is improperly calling .text()?
View 2 Replies
View Related
Nov 22, 2009
My AJAX script runs fine on IE and Opera, but in firefox memory usage raises exponently (sript processes text, more text I use, more memory needed... when I use up to 1000 words, it takes 2 GB RAM on Firefox, while few mb on IE and Opera only).
Is there some way to track memory leak?
View 1 Replies
View Related
Dec 6, 2011
I have this web-app which can also be used offline. However, some content is dynamic (it depends on the user input). What I do now to have it accessible offline, is to store this content into localStorage. However, this works great for text, but what about images!
I've seen examples on the web where the base64 representation of the image-data is used, which is text and can be stored. But how do you get the Base64 of raw image data client-side ?
What would be the preferred way (Assume we don't have a File API) ?
View 5 Replies
View Related