Josh
Josh

Reputation: 141

Proper Switch Statement?

<script language="text/javascript">
var URL = document.URL;
<--switch (URL) {
   case "http://www.greatarchitect.us/defatank":
      document.write("Displaying Defatank");
      break;
   case "seeingblue":
      document.write("Displaying SeeingBlue");
      break;
   case "shiroshii":
      document.write("");
      break;
   case "theend66":
      document.write("");
      break;
   case "wakawaka647":
      document.write("");
      break;
   case "xtheguythatplays":
      document.write("");
      break;
}-->
</script>

What is wrong with the above code? I'm trying to load specific data based on the page URL.

I updated the code. How would I simply display the URL to be sure I'm checking my case against the right url?

Upvotes: 0

Views: 96

Answers (1)

gr3co
gr3co

Reputation: 893

document.URL returns the entire web address. you need to filter/chop it down in order to only manipulate the part you want.

also you're declaring your script wrong. it should be <script type="text/javascript">.

:)

Upvotes: 2

Related Questions