wiki.getshifting.com

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


javascriptreferrer

JavaScript Referrer

Summary: How to create a referrer (redirect) using javascript
Date: Around 2018
Refactor: 1 March 2025: Checked links and formatting.

Use this javascript to set a referrer, meaning that if a user visits a page directly it gets referred to the main page. This way you enforce users to always use the mainpage:

<script type="text/javascript">
if (document.referrer !== "http://mainpage.url.com/") {
    window.location.href = "http://mainpage.url.com/";
}
</script>
javascriptreferrer.txt · Last modified: by 127.0.0.1