DOM Nodes As Keys To A Hash Table

Oct 28, 2005

I want a hash table where DOM nodes are the keys. In Rhino, I can just
use the node objects directly as the keys, since the Java objects that
implement the DOM have handy toString() methods that return a unique
string for each object:

var a = {};
a[document] = ...;
a[document.documentElement] = ...;

This is obviously not portable. The portable solution, I guess, is to
come up with a hash function that works usefully on DOM nodes. Has
anyone thought about this problem and come up with a solution? With a
DOM 3 implementation I could even do something like:

var nodes = [];
var nextIndex = 1;
function getIndex(n) {
var i = n.getUserData("NodeIndex");
if (!i) {
i = nextIndex++;
n.setUserData("NodeIndex", i, null);
}
return i;
}

I want this to work with DOM 2 as well, though.

Any ideas?

View 2 Replies


ADVERTISEMENT

Lookup Table...if / Else Vs. Switch Vs. Hash?

Oct 13, 2005

I need to get some user input which will be a six digit number. I will
split it into two character pairs. Each pair will need to be "looked
up", for example:

View 2 Replies View Related

Navigate Table Rows With Arrow Keys

Oct 3, 2005

I just create a neat little AJAX google suggest style drop down, using a scrollable DIV which contains a table, now the user wants to be able to use the arrow keys to navigate the table.

Does anyone know how to do this or know of an example / tutorial on how to do this? Each row and cell has it's own unique ID.

View 2 Replies View Related

Setup A Textbox To Only Accept Specific Keys - Some Of The Function Keys Are Reading As The Same Values As Letters?

Oct 21, 2011

I am trying to setup a textbox to only accept specific keys. The problem is, some of the Function keys are reading as the same values as letters.Ex.

112 - F1 - p
113 - F2 - q
114 - F3 - r[code]....

Is there another way to allow the function keys without enabling all matching letters as well?

View 2 Replies View Related

Programming Function Keys (F1 - F2) Etc As Access Keys

Oct 18, 2009

I am making a php/mysql epos system for my shop which will be run from a browser on my shop PC. I have large buttons which I would like to be able to 'click' by pressing something like the F-buttons at the top of the keyboard. Is it possible to override the standard button shortcuts for a web page. This is only going to be on my shop computer so accessibility is not a problem.

View 2 Replies View Related

Wrap Nodes Between Two Other Nodes In DIV Tags?

Apr 6, 2010

What's the best way to wrap all the nodes between two nodes in DIV tags? Is it possible with the DOM? I have code similar to the following:

HTML Code:

<h3>First header</h3>
<p>First paragraph</p>
<p>Second paragraph</p>

[code].....

How can I achieve this with the DOM, without resorting to doing something like a string replace?

View 2 Replies View Related

Why Are Anchor Nodes Pointing To Href And Text Nodes Pointing To [object?

Aug 6, 2010

Consider following html code
<p id="oliver">
<a id="oliver1" href="/oliver1/">Oliver Twist 1</a>
<a id="oliver2" href="/oliver2/">Oliver Twist 2</a>
<a id="oliver3" href="/oliver3/">Oliver Twist 3</a>
<a id="oliver4" href="/oliver4/">Oliver Twist 4</a>
</p>

Applying JavaScript to above html as following:

[Code]...

Why are anchor nodes pointing to href and text nodes pointing to [object]? As anchor and text both are objects therefore all outputs from indices 0 to 7 should be [object].

View 5 Replies View Related

Getting URL To Hash?

Nov 7, 2009

If I have the following URL:

http://example.com/viewpage.php?id=test

Then when I write a hash the URL goes to:

http://example.com/viewpage.php?id=test#id=nexttest

I have the following code:

function redirectHash()
{
var hash = location.hash;
if (hash){

[Code]....

Currently this code would try and redirect me to http://example.com/id=nexttest

How can I get it so that it keeps everything before the ? and just updates the id part?

View 2 Replies View Related

Location.hash

Jul 23, 2005

Here is my relevant code for an arbitrary page (let's call it PAGE_B):
<body onload="window.location.hash='anchor'">

With this code, if the user goes from PAGE_A to PAGE_B, he will jump to
PAGE_B#anchor after PAGE_B has fully loaded. BUT... if he clicks the
back button, instead of returning to PAGE_A (which is what I want), he
will return to PAGE_B (without the anchor).

Is there any way to change this behavior... perhaps to replace the
anchor of page without touching the history stack?

View 1 Replies View Related

Using The Hash Value Properly. Js/php

Jan 20, 2007

For my links I have two portions. The first is the regular href for people that don't have javascript can navigate the site and the next an onclick for those with javascript can load pages inline with transitions and have it stay in their history for Firefox. All a la that wonderful ajax stuff everyone knows about by now.

It seemed like a good idea at the time...
Because it is stored in the #hash value these people can link another person that has javascript enabled as well to the page and have the page load. But that's it. So we have 96% some odd percent of users included.

There is going to be confusion that happens if someone sends a link to someone without javascript, since it will just load the home page.

From what I have researched.. the server doesn't pick up the #hash value (this is obvious since when you click on a link that's linking to a spot in the page, it's the browser doing the work). That's okay, the thing I want anyway is for it to pick up on the very first request via well.. something. The first request is when the server does do something and may have a chance to do something with a hash value.

So questions:
1. Can I manipulate the server into 'reading' this #hash value on the initial request and then put it through say.. php or mod_rewrite?

2. What about css.. this is another client end thing that could work, but I am completely lost when it comes to css and recognising hash values. Even if it just works for Firefox/MSIE/Opera.. well.. that's something as it's non-intrusive and ups the people that can access my site properly.

There is an option to post a noscript tag to notify users on the first load that their javascript is off.. but there's no way for php to also be smart and say "hey, there's a Hash value"... as it could, I would just load the page that way. Code:

View 2 Replies View Related

JQuery :: Use Map On A Hash?

Jan 21, 2010

I have a hash which I need to loop-through. [code]...

View 3 Replies View Related

Unrecognizable As An MD5 Hash - Looks Like Hexadecimal ?

Oct 25, 2011

It came up as unrecognizable as an MD5 hash and it looks like hexadecimal to me. Can someone help me convert it to what it is supposed to say? I think it is a series of numbers but am not entirely sure.

View 4 Replies View Related

Js - Add Hash To URL Without Scrolling Page

Sep 17, 2009

the problem with ajax is that the page content generated cannot be bookmarked, nor does the back button work (in some browsers), ive read about history libraries and all sorts of heavy stuff, but i would like to know one simple thing.i want to add a Code JavaScript:

window.location.hash='#';

upon a link click, but theres a catch, when this hash add's, i don't want the screen to jump to the top, i want it to remain where it is.clarification:

1. i open page
2. i scroll down
3. i click link that adds a hash (maybe with a value #test)
4. the page MUST not scroll back to the top.

note: i see that adding a hash has different effects in different browsers, is there a cross browser way?

View 2 Replies View Related

Hash Change On Forum

May 9, 2011

I need to change the way a form on my page works. As currently when you enter in the form information and hit send, you get sent to another page that loads up for testing purposes a basic 'message sent' message. I want the HTML page to load within the ID#Contact which is stylized with a width and a height. I've been directed to the following procedure but I don't know how to make it come together.

jQuery.post() jQuery API
.load() jQuery API
.ready() jQuery API

View 24 Replies View Related

Detection Change Of Location.hash

Aug 18, 2005

A page I have shows a different background colour depending on the
hash portion of the url as it is first loaded. For example a link to
mysite/mypage#0000FF would result in a page with a blue background. But
another link, this one to mysite/mypage#FF0000, would not give me a red
background if directed to the window where mypage#0000FF was loaded
just one moment ago. This is normally to be expected, because the browser
thinks same page, no load event, basta.

If I use the search portion, for obvious reasons, that is treated a new page
load, even when it is from the cache, but I need the hash here. So how do I
detect in mypage the moment when the hash string is changed by a user click
event on another page in another window, perhaps even from another domain?

View 7 Replies View Related

Running Array And Hash In Parallel

Mar 3, 2007

I'm using an array to store map features (name, lat, lon, caption,
etc), from which the user can then select an individual feature. The
problem is that when thousands of features are stored in the array,
looping over the entire array looking for a match is SLOW.

So I'm running a hash in parallel, where every time a feature is
pushed onto the array it's name is also added to the hash as an
identical key value pair. I then check if the key is defined in the
hash, and if it is, I want to use that feature's values from the
array. Problem is, I don't know the index number in the array for this
feature. Is there a way to look this up without looping over it, by
matching values between the array and hash? Code:

View 9 Replies View Related

Location.hash Does Not Work Without SetTimeout

Jul 23, 2007

Basically, my problem is exactly as described in the subject. The
problem is somewhat intermittent and unpredictable, but the majority
of the time if I just have a statement such as

window.onload=location.hash('somewhere');

the URL is indeed appended, i.e. www.example.com/index.php#somewhere,
but window itself doesn't actually move to the bookmark. However, if
I do something like

window.onload=setTimeout("location.hash('somewhere')",0)

it works fine. On very large pages, the timeout actually has to be a
second or two. Any idea why this is happening? I don't know much
about JS, but my thought is that it's trying to move to that bookmark
before it has actually been loaded in the page; the timeout forces it
to wait for the rest of the page to load before going to the bookmark.

View 2 Replies View Related

Pass Hash As Function Parameter

Aug 14, 2007

can i pass a hash as a function parameter. ive seen it been used
before but i can't figure out how to do it.

i would like to call a function like this for example

doSomething({variable1:"blabla",variable2:"blabla"});

how would function doSomething be written for this to work.

I would also like the hash to be optional and the variables in the
hash to be optional.
meaning i should also be able to call doSomething(); with no variables
in it.

View 3 Replies View Related

JQuery :: Get Current URL And Use Hash Variable Later?

May 17, 2011

I am trying to get a slider (slidedeck) to open to a certain slide when the page loads according to the current url.

[Code]...

I'm really new to JS so I'm not even sure if this is the best way to go about this, but SlideDeck don't offer support for linking to a specific slide when using their WordPress plugin (which is poor form I think) so I need to figure it out myself.

View 4 Replies View Related

JQuery :: Hash Location But Different Files?

Sep 25, 2011

I am trying to make sense of the location hash etc. However, I have a few issues that I need to overcome in the process.I have 3 tabs, which need to create a hash and then allow return to that tab on page reload.This is what I need doing: firstly, I need to check the filename accessed and if it is the correct filename (say 'testing.php' or 'testing') then I need to check the GET parameters to see which ones have been called and exist, THEN I need to check the hash to see which tab to load.

View 4 Replies View Related

JQuery :: Load Content From Hash In Url?

Jul 27, 2011

How can retrieve files by using the url hash , and loading them into the # content div ? and how can
I get the hash to look like /#!

[Code]...

View 1 Replies View Related

URL Hash Attribute Triggering Action?

Aug 14, 2011

I am currently learning jQuery and am setting up a site which sells T-Shirts. The products page lists the same T-Shirt in 3 colours:

iMMAculate HTML Prototype / 10.05.11 / Product 1

When the user clicks on one of the colours, e.g. Charcoal, the page loads with the hashtag on the end #Charcoal, so:

iMMAculate HTML Prototype / 10.05.11 / Product 1

Currently I have the page set up so when the user clicks on one of the colour swatches, it loads the images and the colour name onto the page. However, what I would ideally like to have is for the page to load the relevant colour images and h2 span (colour name) that is generated in the URL sorry does that make sense?

View 2 Replies View Related

Location.hash Not Changing History In Ie6?

Oct 10, 2008

I have a problem with IE and location.hash. If I change the hash, the history doesn't "update" and it only keeps one record of the URL. This whole website is AJAX-driven and I need the user to be able to use the forward and back buttons in the browser. Everything works fine and dandy, tested on all the major browsers on PC and Mac, except for IE (both 6 and 7).

In case I wasn't clear, here's a way to reproduce in IE6/7:

Go to google.com
Go to yahoo.com#one
Go to yahoo.com#two
Click back. You'll be back to google.com instead of yahoo.com#one

View 5 Replies View Related

Loading Content Into DIV By Retrieving Hash?

Apr 19, 2010

I have this side bar with a whole bunch of links and I wish to load content into a div directly across from it. The links will be hashes (eg example.com/#foo/bar), then the JavaScript loads the content either into a div and updates a SPAN with the page name. I only have the iFrame version so far, so can someone help me on how to improve this and actually load the content instead of an iFrame? So far I have this code:

<script>
function goto(url) {
if (location.hash != url) {

[code]....

View 1 Replies View Related

Associating Keys To A Function

Jul 24, 2005

I wonder if I can associate some keys (e.g. 'Ctrl+T') to some function I create with JavaScript on my webpage.

View 2 Replies View Related

Safari, Key[down|up] With Cursor Keys

Jul 28, 2005

I'm writing some stuff where I wish to allow the cursor keys to control
elements in a page. This has not been a problem except with Safari
which appears to duplicate the keydown and keyup events which are fired
when the cursor keys are pressed. I.e. pressing and releasing say, K,
results in one keydown event followed by one keyup event. Press any of
the cursor keys results in two keydown events followed by two keyup
events.....

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved