467,161 Members | 1,082 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,161 developers. It's quick & easy.

Using a Variable in an <a href statement

I would like to be able to open a link utilising a variable as the destination. Something like <a href=variablename><\a> where variablename specifies a page address within the website. But I can't work out how to parse the variable into the href statement.

Basically I'm trying to produce a sort of breadcrumb trail, such that at the top of each page a user has a sequential list of the pages he has visited up until now - these are passed url encoded (it's simple and it doesn't need to be secure). I then strip the passed variable to get the previous page name. I would just like to make the sequential list clickable, such that a user can go back to any page he has already visited.

This may be a complete waste of time, but hey, I want to do it!
Mar 14 '07 #1
  • viewed: 18300
Share:
7 Replies
drhowarddrfine
Expert 4TB
If you mean something like paragraph 10 of a web page, try this:

If your web site is www.example.com/mypage.html, on the tenth paragraph you would do this:

<p id="thisparagraph">
Some text
</p>

Then, in the anchor of the referring page, you would do this:

<a href="www.example.com/mypage.html#thisparagraph">

Clicking on that link will then jump down to that paragraph of the page.
Mar 14 '07 #2
Not quite what I mean I'm afraid.

I've got the site set such that each preceeding page passes it's address to the next page via url encoding (i.e. www.site.com?page=page1.html).

The next page picks up the "page" variable. I would like to use that variable in an <a href statement, such that when I display the sequential list of previously visited pages (using the same variables passed by previous pages), they are displayed as links such that the user can use them to backtrack.

I know one can use the history in Javascript, but that doesn't give the explicit page addresses, (only -1 or -n etc ) which is not what I want.

Cheers
Mar 14 '07 #3
drhowarddrfine
Expert 4TB
Neither html nor css would be able to do that so you would need a server side language/program.
Mar 14 '07 #4
Thanks for that.

Bums - or other epithets. No wonder I couldn't find anything on the web. I take it that includes Javascript? It seems such a simple, straightforward thing.

Cheers
Mar 14 '07 #5
Expert 1GB
Thanks for that.

Bums - or other epithets. No wonder I couldn't find anything on the web. I take it that includes Javascript? It seems such a simple, straightforward thing.

Cheers
Yes Javascript is server side. You could do it in PHP or ASP. Here is a link to our PHP forum.

HTH,
Aric
Mar 14 '07 #6
I think this is what you want:

Expand|Select|Wrap|Line Numbers
  1. <xsl:text disable-output-escaping="yes">&lt;a herf="</xsl:text>
  2. <xsl:value-of select="theUrl"></xsl:value-of>
  3. <xsl:text disable-output-escaping="yes">">Click Me&lt;/a></xsl:text>
  4.  
Sorry, for my poor typing. It should be href not herf.
May 28 '10 #7
drhowarddrfine
Expert 4TB
We can forgive you for typos but not for bringing up 3 year old threads.
May 28 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Japhy | last post: by
8 posts views Thread by Kathleen Dollard | last post: by
1 post views Thread by neilpeel | last post: by
1 post views Thread by shalini jain | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.