If user came from previous page on site then this, else do this
<p>What would be a viable way to accomplish the following:</p>

<p>A website has two pages; Parent page and Inside page. If user came to the Inside page directly by typing in the address or by following a link from a page other than Parent page, then show "foo". If user came to the Inside page from the parent page, then show "bar". </p>

<p>I would need this done in JS if possible. If not, PHP is a secondary choice. </p>