Steven Matthews
Steven Matthews

Reputation: 11285

Javascript to determine what page I'm on

So I have an image which displays on every page, however I'd like to write a script that will, depending on the page, replace the image with another image. How would I programmatically determine what page I am on? The actual image replacement I can already do.

Upvotes: 0

Views: 1444

Answers (1)

Gabe
Gabe

Reputation: 50493

You could use location

<script type="text/javascript">
   alert(window.location);
   // and you can set the location to move to another page
   window.location = "http://stackoverflow.com"
</script>

Upvotes: 3

Related Questions