5 replies [Last post]
obliocat
obliocat's picture
Offline
newbie
Last seen: 18 years 44 weeks ago
Joined: 2004-01-23
Posts: 9
Points: 0

i would like to incorporate some if then else statements into a nav i'm building. basically, i want have the script look to see what page the user is on and display the menu item with a particular class based on location. when the site i worked on was html/apache, i did it like this:

<!--#if expr="\"$DOCUMENT_URI\" = page1.shtml/" --> 
<span class="red">Page 1</span> 
<!--#else --> 
<a class="blue" href="page1.shtml">Page 1</a> 
<!--#endif -->
<br>
<!--#if expr="\"$DOCUMENT_URI\" = page2.shtml/" --> 
<span class="red">Page 2</span> 
<!--#else --> 
<a class="blue" href="page2.shtml">Page 2</a> 
<!--#endif -->
<br>
<!--#if expr="\"$DOCUMENT_URI\" = page3.shtml/" --> 
<span class="red">Page 3</span> 
<!--#else --> 
<a class="blue" href="page3.shtml">Page 3</a> 
<!--#endif -->

now the site i'm working on (did not build) is .asp on an IIS server and i know nothing of the scripting....

can someone give me a hand?

Smile obliocat

Tags:
obliocat
obliocat's picture
Offline
newbie
Last seen: 18 years 44 weeks ago
Joined: 2004-01-23
Posts: 9
Points: 0

got it

just in case someone else searches for this... i have finally gotten an answer:

<% 
if instr(request.ServerVariables("SCRIPT_NAME"), "page1.asp") > 0 then 
    navStyle = "red" 
else 
    navStyle = "blue" 
end if 
%> 
<a class="<%=navStyle%>" href="page1.asp">Page 1</a>

Smile

hke8jc- spam bot
Offline
newbie
Last seen: 15 years 42 weeks ago
Joined: 2007-02-08
Posts: 2
Points: 0

why not cms


Mod edit:
Spam links deleted.

Hugo.

rmfred
rmfred's picture
Offline
Elder
Rock Springs, WY
Last seen: 4 years 7 weeks ago
Rock Springs, WY
Timezone: GMT-6
Joined: 2004-01-31
Posts: 1073
Points: 31

I've used ASP in the past to

I've used ASP in the past to do just this... but you may be able to do away with all the scripting and just use CSS to accomplish it. I say may, because I don't know the overall scheme of what you're doing.

You can give your Body an ID and use that for your navStyle:
Example:

HTML:

<a href="/page1.asp" id="p1nav" rel="nofollow">Page 1</a>
<a href="/page2.asp" id="p2nav" rel="nofollow">Page 2</a>

CSS:
body#page1 a#p1nav {color:red;}
body#page2 a#p2nav {color:blue;}

Just an idea

thepineapplehead
thepineapplehead's picture
Offline
Moderator
Last seen: 31 weeks 1 day ago
Timezone: GMT+1
Joined: 2004-06-30
Posts: 9683
Points: 819

Psssst . . . . the thread is

Psssst . . . . the thread is three years old Wink

Verschwindende wrote:
  • CSS doesn't make pies

rmfred
rmfred's picture
Offline
Elder
Rock Springs, WY
Last seen: 4 years 7 weeks ago
Rock Springs, WY
Timezone: GMT-6
Joined: 2004-01-31
Posts: 1073
Points: 31

Hahahahahaha... that's just

Hahahahahaha... that's just too funny. Didn't even notice that. Sorry.