Webnerdoz
Webnerdoz

Reputation: 165

Dynamically change text based on URL input

I am using the following code to dynamically change the text on my clients website (www.mydomain.com.au):

<script type="text/javascript">// <![CDATA[
       var url = window.location.toString();
       var query_string = url.split("?");
               if (query_string[1]) {
       var params = query_string[1].split("&#038;");
       var param_item = params[0].split("=");
       param_item[param_item[0]] = unescape(param_item[1]);
       document.write(param_item["city"]);
               } else {
                       document.write("24 Hour Glass Replacement");
               }
// ]]&gt;</script>

It works perfectly fine on the index page. e.g. www.mydomain.com.au/?city=test

but when I am using the same code on other pages e.g. http://www.mydomain.com.au/Brisbane.html/?city=test I get a 404 error.

Appreciate any help

Upvotes: 1

Views: 3014

Answers (1)

Shahdat
Shahdat

Reputation: 5483

Remove the / before starting querystring. So, try http://www.mydomain.com.au/Brisbane.html?city=test instead of http://www.mydomain.com.au/Brisbane.html/?city=test

Upvotes: 1

Related Questions