1
roojo
Dinamic header Image from parameter in URL
  • 2006/8/28 21:55

  • roojo

  • Just popping in

  • Posts: 3

  • Since: 2005/5/7 1


Hello, i don't know if this will be of any use to someone else, but i had a friend who wanted to have different image headers for his news topics and so poking around the net i found a javascrit to get the value of a param and used it for it.

here is the code.

function getURLParam(strParamName){
  var 
strReturn "";
  var 
strHref window.location.href;
  if ( 
strHref.indexOf("?") > -){
    var 
strQueryString =
strHref.substr(strHref.indexOf("?")).toLowerCase();
    var 
aQueryString strQueryString.split("&");
    for ( var 
iParam 0iParam aQueryString.lengthiParam++ ){
      if (
aQueryString[iParam].indexOf(strParamName "=") > -){
        var 
aParam aQueryString[iParam].split("=");
        
strReturn aParam[1];
        break;
      }
    }
  }
  return 
strReturn;
}

var 
topic getURLParam("storytopic");

switch(
topic)
   {
      case 
"1":
                        
document.writeln('');
         break;
      case 
"2":
                        
document.writeln('');
         break;
      case 
"3":
                        
document.writeln('');
         break;
      default:
                        
document.writeln('');
         break;
   }


getURLParam("storytopic");

returns the value of storytopic wich according to the switch display the image requiered or a default image if theres no value.

i think this is usefull for theme presonalitation, anyway there you have it...

All the best.

Login

Who's Online

450 user(s) are online (334 user(s) are browsing Support Forums)


Members: 0


Guests: 450


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits