Forum Moderators: open
When i use <a href="different_wbpage.html #id> it seems to work when i preview on my browser, but when i upload my site the links dont work ?
I have tried to search it but no luck, i believe you can only link to an #id on the same doc but just wanted to clarify.
thanks in advance
Was just wondering if it was possible to create a link to certain section(#id) on a different webpage?
Absolutely. You can even create links to other websites that utilize Fragment IDs.
Your using a relative path to reference the ID. To make it work cross site, use root relative paths like so...
<a href="/sub/different_wbpage.html#id"> When linking to third party documents with a Fragment ID.
<a href="http://www.example.com/sub/different_wbpage.html#id"> Be careful, Fragment IDs ARE case sensitive. I will normally cut and paste those to avoid retyping and introducing errors. ;)
[edited by: pageoneresults at 2:48 pm (utc) on Oct. 26, 2009]
What you report is a mystery to me, especially because you say it works locally for you. Does the link not even open the correct page? or just not jump to the correct spot?
<a href="different_wbpage.html #id>
There's a space there between the Fragment and then we're also missing a closing quote. I was thinking maybe the OP put the space in there to prevent the system from doing something, and forgot the closing quote. ;)
some-script.php?s=1234#headId
Tip: don't use identifiers like "id" or "ID" - these may or may not conflict with the DOM if you use any Javascript.
Per P.1.R.'s thread [webmasterworld.com], one of the nuggets to be gleaned there and the various links in that topic opener is you don't need to use an anonymous anchor to do this (and shouldn't, is a waste, is less semantically correct:)
<a name="headId"></a>
Apply the identifier to a valid document element, it works just as well.
<h3 id="headId">Topic three</h3>
<p id="topicThree">Text of topic three</p>
It's the little things in developing pages than makes them better, smarter, easier to maintain.