How do I run a script on a page only if the page was opened from another page?
I have this page element:
<div id="Devotion_alert"></div>
I add a span with onclick to that div.
var show_devotion_alert = '<span style="cursor:pointer;" onclick="open_livemass();"><br/>'+devotion_name+' '+time_info+'<br/>('+devotion_channel.name+')</span>';
$('#Devotion_alert').html(show_devotion_alert);
When the user clicks on the element I want to run a script:
function open_livemass() {
window.location.href = 'livemass_RECORDED.php';
// want to select elements on the new page and load element content
}
When the new page loads I want to select page elements and load element content. I only want to do that if the new page was opened with a mouseclick from the previous page.
OK. Found that the most practical solution was to send variables in the URL to tell the new page what to do. If the variables are not there, the page will be the same as if it were opened directly. If the variables are there, a javascript function will load the page elements.
From the referrer page onclick I open the new page with this:
In the livemass_RECORDED.php page I read the variables and fill the necessary elements.