html - Server Side Includes with variable (IIS 7) -


i trying build universal header file can include in each .html file on site. header contains several dropdown tabs, , 1 of tabs highlighted (depending on page user on). want server side include header, want give variable knows tab highlight, this:

<div class="topmenu"> <ul> <somescript> if (variable=="home") {    print "<li class='current'>"; } else {    print "<li>"; } </somescript> ... 

my server iis 7 , doesn't support php, , don't want rename files *.asp can use asp. how go this?

by extension guess use classic asp. should work:

<!--#include file="header.asp"--> 

you can put in each file want have header. of couse, should create "header.asp" page first ;)

for highligthing tab of page you're in, there're several methods. imho, suggest clientside script that. js or jquery of course.

you check file name of url in , give proper class tab highligthed.

example ( jquery needed ):

var currentpage = window.location.pathname.substring(url.lastindexof('/')+1); if(currentpage == 'default.asp') $('li.homepage a').addclass('current'); 

this simple code retrives file name and, it, add class corresponding element in navigation.

of course conceptual script, you'd better adapt page.


Comments