473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

"#" prefix for location.hash?

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.

Thanks,

Yimin Rong
Jul 20 '05 #1
1 9874
I don't think this is a JS question as you can do hash anchors in html href
code.

I think you will find that if you put a <a name="#hashname"></a> in IE it
will work and in netscape it won't (new versions of NS might work).
IE is more intelligent than netscape so works out bad code and does work.

The answer is, in the <a name="anchorname"></a>, miss out the hash (#) and
this will work in all browsers. Only on the link that goes to that
page/section of the page do you put the hash symbol.

<a href="page.html#intro">link</a>

<a name="intro"></a> Your intro text.

This will work in all browsers.
Hope that helps.

Stu

"Yimin Rong" <yi*******@yahoo.ca> wrote in message
news:af**************************@posting.google.c om...
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.

Thanks,

Yimin Rong

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Anthony Baxter | last post by:
To go along with the 2.4a3 release, here's an updated version of the decorator PEP. It describes the state of decorators as they are in 2.4a3. PEP: 318 Title: Decorators for Functions and...
11
by: John Velman | last post by:
I've used perl for a lot of 'throw away' scripts; I like Python better in principle, from reading about it, but it was always easier to just use perl rather than learn python. Now I'm writing a...
1
by: RzB | last post by:
In a previous post in this NG (Oct 98) http://makeashorterlink.com/?D505347FB Henry Craven says that he was investigating a relationship between the presence or absence of a "Me!" prefix, the...
10
by: Clint | last post by:
Hey all - I'm having a really confusing problem concerning a web service. Right now, I have an application that needs to call a web service that does nothing but return "true" (this will...
7
by: Clint Herron | last post by:
Howdy! I posted this question on CSharpCorner.com, but then realized I should probably post it on a more active newsgroup. This will be my only cross-post. I'm creating a game engine, and...
1
by: francescomoi | last post by:
Hi. I compiled PHP by using: -------------- './configure' '--prefix=/usr/local/php' '--with-apxs2=/usr/local/httpd/bin/apxs' '--with-mysql=/usr/local/mysql'...
13
by: Steve | last post by:
Hi; A friend of mine is publishing a book that includes 3000 citations, many with urls. When he made his bibliography he chopped off the "http://"s off of his urls. I wrote a program to...
12
by: Matthew Wilson | last post by:
Hi, we are getting a lot of spam through our PHP Feedback form, and have set up a new field 'prove you're human', asking them to do some simple maths. What is the command for the PHP script...
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.