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.

le="color: #000000"><?php function getURLParam(strParamName){ var strReturn = ""; var strHref = window.location.href; if ( strHref.indexOf("?") > -1 ){ var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase(); var aQueryString = strQueryString.split("&"); for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){ if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 ){ var aParam = aQueryString[iParam].split("="); strReturn = aParam[1]; break; } } } return strReturn; } var topic = getURLParam("storytopic"); switch(topic) { case "1": document.writeln('<img src="image1.jpg">'); break; case "2": document.writeln('<img src="image2.jpg">'); break; case "3": document.writeln('<img src="image3.jpg">'); break; default: document.writeln('<img src="default.jpg">'); 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

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits