Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using the Page Title to make links active or not!

Status
Not open for further replies.

MahendraMahey

Programmer
May 13, 2003
13
GB
I am working in vbscript and I want use the Page Title, assign it to a variable and then use it to display a navigation link as active or not.

For example:

<TITLE>International<TITLE>


Links

Home Regional National International


Code should be something like this:

If pageTitle=&quot;International&quot; Then display 'International'
Else display '<A HREF=&quot;../international/index.asp&quot;>International</A>

How would I do this as I have come to a mental block and I need it urgently.

Thanks

Mahendra
 
maybe something like this?
title = &quot;<title>international</title>&quot;
if title = &quot;<title>home</title>&quot; then
response.write title
else
response.write &quot;<a href = 'title'>title</a>&quot;
end if

hth
mb

&quot;Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!&quot;
Marvin the Martian
 
Thanks for this but what I need is this


1. Get the document title
2. Assign it to a variable
3. In a table cell insert the code that would do the following:

If the document title corresponds to the document title for the page of the link then make that link inactive else keep it active e.g.


e.g.

Nav links

Home Regional National International


In the 'International cell' put in code that says if page title corresponds to the page title of the page when I click 'International' then only display text otherwise (if I don't click it') just display the link.

Do you understand?

Mahendra

(THanks for helping so far)
 
not completely sure I understand. Let me attempt to say it back and correct me where I'm wrong.

You have a page with a table. You want to grab the title of that page and store it as a variable. In the table you have the home, regional, national and international links. What I think you're asking is that if the page title matches the link, then it's an href else not. so:
if i'm on the &quot;international&quot; page, the only active link would be the international link but if i'm coming from the regional page, only the regional link is active.

if that's correct, I don't know of a way (not to say it doesn't exist) to get the page title from the html. you could pass it as a variable in your url (i.e. regional.asp?title=regional) or (shudder) as a session variable or write it to a cookie that retrieved by the next page and request it in. possibly have a case statement for the files availble and use that to determine whether the link is active or not.

sorry if i've missed the mark.
hth
mb

&quot;Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!&quot;
Marvin the Martian
 
Almost!

I have many cells in which I want to put navigation links, e.g. Cell 1, Regional, National, International

What I want is:

assign a variable to contain the value of the page title (I think this is document.title).

e.g. title=document.title

Then in each cell there will be a conditional statement. The Conditional statement will read something like this:

If title=&quot;Regional News&quot; then write 'Regional'

Else write &quot;<A HREF=&quot;regional.htm&quot;>Regional</A>

In the next cell there will be another conditional statement

If title=&quot;National News&quot; then write 'National'

Else write &quot;<A HREF=&quot;regional.htm&quot;>National</A>


So...

All my navigation elements on the page are built up by conditionals. If I am on the page 'international' then ONLY TEXT is displayed in the cell. Other cells have navigational links in them EXCEPT the 'International' one.

Do you get it?

Could you show us the code?

 
Sorry code should read:

Then in each cell there will be a conditional statement. The Conditional statement will read something like this:

If title=&quot;Regional News&quot; then write 'Regional'

Else write &quot;<A HREF=&quot;regional.htm&quot;>Regional</A>

In the next cell there will be another conditional statement

If title=&quot;National News&quot; then write 'National'

Else write &quot;<A HREF=&quot;national.htm&quot;>National</A>
 
I should point out that EACH CELL has DIFFERENT navigational element in it:

e.g.

Cell 1 - Regional
Cell 2 - National
Cell 3 - International

And so on...
 
okay, I'm coming in from the &quot;international&quot; page:
<table><tr>
<td>
<%
title = document.title
if title = &quot;international&quot; then
response.write &quot;International&quot;
else
response.write &quot;<a href = 'international.asp'>International</a>&quot;
end if
%>
</td>
<td>
<%
if title = &quot;regional&quot; then
response.write &quot;Regional&quot;
else
response.write &quot;<a href = 'regional.asp'>Regional</a>&quot;
end if
%>
</td>

etc. etc. for as many cells as you have, then close the row and the table. this is presuming that document.title does indeed retrieve the title (seems reasonable that it should).

hth
mb



&quot;Where's the Ka-Boom? There's supposed to be an Earth-shattering Ka-Boom!&quot;
Marvin the Martian
 
Thanks for this.

Will try it and get back to you.

By the way if this works it is a great timesaver in creating accessible websites as the recommendation is that when desinging websites for blind users you should always ensure that once they have clicked on a page that and got to it, the link is no longer active.


Get back in a moment!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top