Welcome to WebmasterWorld Guest from 54.159.246.164

Forum Moderators: incrediBILL

Message Too Old, No Replies

base URL and anchors

Is it possible for base URL and anchors to work together?

   
10:42 am on May 29, 2004 (gmt 0)

10+ Year Member



Hello

I am using base url within an HTML document - say http: //www.website.com/

I am also using anchors e.g <A name=Top></A> and later on down the HTML page <A href="#Top">Top of Page</A>

But the anchors are taken in relation to the base url and open a page "http://www.website.com/#Top". Is there a way for the base url to distinguishing between anchors within an HTML page and all other links?

Many thanks for an help received

Alina

[edited by: BlobFisk at 10:48 am (utc) on May 29, 2004]
[edit reason] Delinked example URL [/edit]

11:21 am on May 29, 2004 (gmt 0)

10+ Year Member



By setting the base you are instructing the browser to resolve all urls relative to that base. The browser is doing exactly what you're telling it to do.

If the page this is happening on is "http://www.website.com/foo.html", your links would have to be <a href="foo.html#Top"> so when resolved relative to the base, you get the answer you first thought of. Or you could use absolute urls (ie <a href="http://www.website.com/foo.html#Top">).

3:44 am on May 30, 2004 (gmt 0)

10+ Year Member



That's not an HTML problem; that's a browser problem. [example.com...] should be a valid URL.

Requesting a URL with a '#' is a two-step process: The browser requests the file (without a # or anything after it) from the server, then searches the returned file for the target anchor.

9:13 am on May 31, 2004 (gmt 0)

10+ Year Member



Thanks for your both your replies.

py9jmas: I am trying to send the html within an email message. I could change the anchor link to foo.html#Top - which would work.

The only thing is when the anchor is clicked on - instead of scrolling within the actual email message - a new window gets opened.

I would like scrolling within the email message to be achieved. Is there any way that this could be done?

Many thanks

Alina