Cleaning Up The "hash" Part Of The Location
Dec 30, 2005
I don't like the way that a link to page top leaves the location bar with something like '#top' appended to it.
So, I'm hooking a listener to the link click event, doing a window.scroll and stopping default action. This is fine as long as the location doesn't already have a hash portion. When it does, I'd like to clean that up without causing a page reload or any server requests.
Is this possible? The closest I got with MSIE is to remove the tail end, but I can't get rid of the actual '#'.
View 6 Replies
ADVERTISEMENT
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
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
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
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
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
Aug 24, 2011
To make a long story short when I do a redirect like this...
Code:
if(window.location.hash.length > 0){
window.location = "http://" + "<?php echo $_SERVER['HTTP_HOST']; ?>" + "/" + window.location.hash;
}
it goes there, but on the refresh php can't see what was appeneded with the window.location.hash, so its like I'm going to
[Code]...
View 3 Replies
View Related
Nov 29, 2005
Is it possible to notice a change of window.location.hash without
polling?
I'm working on a Ajax-platform (yes, inventing the wheel again) and
have finished almost everything except the support for
back/forward-buttons. The track I'm working on is "hidden frames" to
keep state in window.location.hash. I've seen some solutions along this
way that includes polling window.location for a change... which doesn't
comply with my otherwise strict event-driven design...
View 2 Replies
View Related
Aug 10, 2010
What I want is a textbox that the user can enter information into. When they press a key the onkeyup event will simulate a function. All that I can do. The function needs to automatically scroll down the page to the anchor that corresponds to the number the user entered. The web page is a factor finding program. You can enter 2 numbers and it finds all the factors of all the numbers between the 2 you entered. Here is the link: [URL] As you can see, when you try to find factors of numbers a new window opens and there is a search box in the top left. Unfortunately, it doesn't work. If you want to check out the code look at the web page but here is the bit that creates the new window
[Code]....
View 6 Replies
View Related
Mar 13, 2009
I'm attempting to implement some deep-linking in my simple AJAX application by setting location.hash, and I've run into two problems:
1) Sometimes setting location.hash seems to send the window on both IE and FF to scroll to the top of the page. I do not want any scrolling to occur. The location.hash change happens in a function which is triggered in an onclick event.
2) Changing location.hash creates a history entry on FF (not on IE)... that's pretty cool for FF, but in this case I do not want a history entry created. How can this be avoided?
I found an example which seems to have avoided both these problems, but cannot decipher the pertinent code: [URL]
View 6 Replies
View Related
Jul 7, 2009
I am writing a modification to Invision Power Board that makes replying to post via Ajax.
The "Submit" button is being overrun by Prototype's observe function. When the custom function is executed, I run Event.stop(e) to prevent the actual form from being submitted and reload the page.
I have developed and tested on Safari but users began to report bugs in IE, after investigation I discovered that the line
Code:
Is making IE execute all the code after it, and then execute its own onclick() function as if Event.stop(e) was not there. Commenting this line fixes the problem, the page is not reloaded, but this line is vital to the code.
So why do I need to set the anchor? To support the back button function after a user makes an ajax reply, pressing Back should hide the new content, and pressing Forward should make it visible. (e.g. every time the anchor is changed) This all works nicely. But not in IE.
This only happens the first time the page is visited ever, or clearing cache and visiting it again. Reloading the page fixes the problem but this is not normal behavior and users shouldn't have to reload to use the Ajax fast reply...
View 4 Replies
View Related
Jul 20, 2005
Does anyone know if there are any browsers where you must specify "#"
as a prefix when setting the hash for the location?
For example, the following would move to the intro section of the
document:
window.location.hash = "#intro";
But in the same browser, this would not work:
window.location.hash = "intro";
So far, in the browsers I've tested, the "#" seems to be optional. If
this behaviour is compliant, any references, on-line or otherwise,
would be welcome.
View 1 Replies
View Related
May 12, 2007
I have a preloading page on my site for several images. When I run the code for the preloading page through the W3 validator, I get these error messages:
character "<" is the first character of a delimiter but occurred as data.
there is no attribute "name". document type does not allow element "img" here.
I tried correcting the second and third errors, but ended up messing up the whole script. If someone could fix these errors and just clean up the code in general, that would be helpful. By the way, the doctype is XHTML 1.0 strict. Code:
View 8 Replies
View Related
Sep 29, 2010
I have created the following function to expand a container depending on which one is hovered over, but need some advice on how to tidy it up.
There are four containers in all: three expand to the right and the final one expands to the left. There is a hidden element in the expandable area which appears when the container has fully expanded. For example: if I hover over .sub-main section.other, then the hidden div .other .right fades up. Mouseout and it fades down quickly as the .sub-main section.other retracts.
The working example is here: [URL]
The following code does work, but I am aware that it could probably be reduced to half as many lines using some conditional cleverness:
$(document).ready(function(){
// Hides right or left divs depending on the block
$('.other .right').hide();
$('.end .left').hide();
[Code]....
View 3 Replies
View Related
Sep 29, 2002
const notWhitespace = /S/
function cleanWhitespace(node) {
for (var x = 0; x < node.childNodes.length; x++) {
var childNode = node.childNodes[x]
if ((childNode.nodeType == 3)&&(!notWhitespace.test(childNode.nodeValue))) {
// that is, if it's a whitespace text node
node.removeChild(node.childNodes[x])
x--
}
if (childNode.nodeType == 1) {
// elements can have text child nodes of their own
cleanWhitespace(childNode)
}
}
}
document.addEventListener("load", function() {
cleanWhitespace(document)
}, true)
This script is intended to remove whitespace text nodes from a document. These nodes show up far more often than we want to admit, and leads to a DOM that is different in Mozilla than IE.
Make sure you use this only in documents where whitespace is expendable. XHTML documents are among these, as are MathML expressions and SVG images.
Theoretically, whitespace can be significant in some XML documents.
View 40 Replies
View Related
Oct 16, 2009
I have a search box. I need to remove all the special characters from the search term and then query it.-,?~!@#$%&*+-= all these characters.can anybody suggest a proper regular expression for this ? and the syntax for using it in javascript.my query is saved in var query;
View 7 Replies
View Related
Jun 29, 2009
I have an ajax based page, which loads content from external page (html +js) So if i have a div "update_div" being updated with external content (html+js)
Let me be more specifig
Step1: Ajax content along with js loaded into update_div from a.html
Step2: Ajax content along with js loaded into update_div from b.html
What happens to the js loaded from a.html? Is it lurking in the memory or automatically/magically removed from the browser memory? I am afraid of memory leaks, if the js is still lurking in memory, the more ajax calls made, the more js is going to be held up in memory. Unless am totally wrong; i have no idea of the mechanism happening.
View 11 Replies
View Related
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
Feb 14, 2010
Danged if I can find the thread, but I swear I saw a $.url() reference in here a day or two ago. It was beingutilized for parsing out the window.location or window.location.search parameters. I made a mental note because that was something I would be needing to do.
Now I can't find it, either because the search isn't finding it or I was dreaming about this function existing.
I rummaged about the API docs and didn't find it there either. Is it something provided by one of the plugins and not a function native to jQuery?
View 3 Replies
View Related
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
Jan 21, 2010
I have a hash which I need to loop-through. [code]...
View 3 Replies
View Related
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
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
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
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
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
View Related