/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] HTML anchors keep directing browser to index page

The long and short of it is:
a) If I’m trying to make an <a> tag have “#” as it’s href value such that the page won’t change when you click on it or
b) If I’m trying to reference an element in the page using href=’#htmlelement’

when clicked, the link causes the page to go to my index page (index.html/php/whatever). I have a sneaking suspicion that this might be to do with the doctype, but am unsure. Any help would be much appreciated.

(The context is in my trying to use the mootools multibox.js system to load the contents of an html element into a pop-up window. This requires the href to be set to whatever the element’s ID is but doesn’t work because the page changes location!!!)

Thanks in advance.

to post a comment
HTML

6 Comments(s)

Copy linkTweet thisAlerts:
@CharlesMay 13.2009 — I'm thinking that you have [url=http://www.w3.org/TR/REC-html40/struct/links.html#edef-BASE]BASE[/url] element there that is screwing things up.
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 13.2009 — I think you might have hit the nail on the head!! Is that what that does?

What might the side effects be to removing it?
Copy linkTweet thisAlerts:
@CharlesMay 13.2009 — Then all the other relative links will become relative to the current page, not to the root. If this is for the web, and not the local file system, you could make those other links relative to the root by simply pre-pending a "/".
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 13.2009 — I see. I've removed the base element and that seems to have the desired effect. Am I safe in assuming that this won't screw up any links (all already have "/" prepended to them)?

And thank you very much for solving that.
Copy linkTweet thisAlerts:
@CharlesMay 13.2009 — Never assume (because when you do you ...) but you should be good to go. A little trying it out might settle your question, though.
Copy linkTweet thisAlerts:
@blue-eye-labsauthorMay 13.2009 — I have done. It seems to all be in order.

Thank you very much.
×

Success!

Help @blue-eye-labs spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 11.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @bahaedd,
tipped: article
amount: 1000 SATS,

tipper: @Balmasexy,
tipped: article
amount: 1000 SATS,

tipper: @mbsaad,
tipped: article
amount: 1000 SATS,
)...