By Eric Harlan
Published: February 6, 2009
Updated: February 6, 2009
Print    Email

So while creating the master pages and such for the American Institiute of Aeronautics and Astronautics (deep breath).  They needed a way to tell where the user is on the site and show them a header image based on where they are. For example, if they are on a potential student page they would be shown a student, if on a page for professionals, they are shown a professional etc, etc.  So really the only specific thing that you can stick in a master page (that i could think of at the time) would be something that reads the URL.

So we came up with this script that would read the URL then parse out everything in the main domain and everything after the first SUB site path For example. If a user went to www.ericharlan.com/sitex/123/default.aspx, the script would produce just  sitex .

 

So what we did was created a flash header that had a default random image that would display if the variable came back undefined (which means the user is on a page that isnt defined as one of the variables the flash is looking for OR, there was an error in the script) the image based back was on a random 30 rotation, so the same "error" image would never show twice. Then we would create out site hieracrhy with attention to the subsites, each categroy of the site (students, professionals, etc) having their own set path name. We then create the flash header to look for these subsites (aka the variable the script was passing.And blamo, there you have it site header image based on site location.

Here is the script.

<script language="Javascript">

<!--

var showImage = location.pathname;


showImage = showImage.replace("/", "");

showImage = showImage.replace(/(\/.*)/ , "");


/* document.write(showImage); */ /*Uncomment this if you want to check if the variable is being passed, It will display it at the top of the page*/

//-->

</script

 

 


Submit Article

3256 Views - View Comments (0)

Twitter Feed @ericharlan

Latest Blog

Weight Loss or Bust - So did it work?
Updated: January 2, 2012

SharePoint Search and DisableLoopBackCheck
Updated: December 18, 2011

SharePoint Conferences 2011 + Asia
Updated: November 15, 2011

It’s sick, but I love the turbulence.
Updated: November 15, 2011

Cruise on up to the Med
Updated: October 22, 2011

SPC11 MSPFE Meet and Greet
Updated: September 30, 2011

Ebay, you reek of Idiocy
Updated: July 6, 2011

Hard CORE AD Core setup for SharePoint
Updated: May 31, 2011
  [1] 2 3 ... 16   Next

Blogs I Frequent

Connect

 


  

 

 

Locations of visitors to this page

RSS Syndicator