Guys,

I'm having a little bit of a problem trying to display something when the URL is a specific one.

Basically purely for examples sake, if the URL is http://www.mydomain.com/hello.html I want it to display "Hello", and when it isn't I want it to redirect to another page.

I know how to do it in PHP, but I need to be able to do it in JavaScript. I applied the same principle on how I'd do it in PHP to JavaScript, and I'm not having much luck. He's what I have that doesn't work:

<script type="text/javascript">
var uri=location.href;

if(uri==http://www.mydomain.com/hello) {
     document.write("Hello");
}
else {
     window.location="http://www.mydomain.com/bye";
};
</script>

All your help is highly appreciated.

Thanks,
Brown.

Don't worry solved it! :)

To help those in the future:

<script type="text/javascript">

var uri=location.href;

if (uri=="http://www.mydomain.com/yes") 
     {
          document.write("yes");
     }
else 
     {
          window.location="http://www.mydomain.com/no";
     }
</script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.