Reading Address Before Browser Loads It?
-
I'm writing a simple piece of code to display a popup when somebody leaves my wordpress blog. It will simply ask if they wanted to register for my next open house before they leave the website. Here's what I have...
<script language="JavaScript">
window.onbeforeunload = confirmExit;
function confirmExit()
{
return "Have you registered for my open house tour?";
}
</script>That displays everytime a page is unloaded though... I want to simply check what the next page is and if it doesn't contain my domain then trigger the popup. I found this code but it won't work because it shows the previous pages address when I need to see the next page to loads address.
var s = window.location.href;
var s = window.
return s;Does anybody know how I can grab the next page that will be loaded from the browser? Thanks!
-
I'm writing a simple piece of code to display a popup when somebody leaves my wordpress blog. It will simply ask if they wanted to register for my next open house before they leave the website. Here's what I have...
<script language="JavaScript">
window.onbeforeunload = confirmExit;
function confirmExit()
{
return "Have you registered for my open house tour?";
}
</script>That displays everytime a page is unloaded though... I want to simply check what the next page is and if it doesn't contain my domain then trigger the popup. I found this code but it won't work because it shows the previous pages address when I need to see the next page to loads address.
var s = window.location.href;
var s = window.
return s;Does anybody know how I can grab the next page that will be loaded from the browser? Thanks!
Sorry, but I can only say I hope you will not get a solution ever, as my next page is none of your business! Besides, what if the visitor closes his browser or his browser tab? When he does, there isn't a next page. A better approach could be this: have each of your pages ask the question under some conditions, such as: 1. ask it only once 2. ask it only when the visitor has been on your site for more than 2 minutes 3. ask it only when the visitor has been on the same page for more than 20 seconds :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
Sorry, but I can only say I hope you will not get a solution ever, as my next page is none of your business! Besides, what if the visitor closes his browser or his browser tab? When he does, there isn't a next page. A better approach could be this: have each of your pages ask the question under some conditions, such as: 1. ask it only once 2. ask it only when the visitor has been on your site for more than 2 minutes 3. ask it only when the visitor has been on the same page for more than 20 seconds :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
Sorry, but I can only say I hope you will not get a solution ever, as my next page is none of your business! Besides, what if the visitor closes his browser or his browser tab? When he does, there isn't a next page. A better approach could be this: have each of your pages ask the question under some conditions, such as: 1. ask it only once 2. ask it only when the visitor has been on your site for more than 2 minutes 3. ask it only when the visitor has been on the same page for more than 20 seconds :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
I'm fairly novice when it comes to Javascript. What variables store these conditions / time on page? I understand I'll probably write a cookie so it only alerts the visitor once. I do like the idea of prompting them after they've been on the site for a certain period of time. fyi. My goal is simple. People may have not noticed the information they need so I want to indicate such. I just want to provide a little alert box or something to redirect them if they choose.
-
I'm fairly novice when it comes to Javascript. What variables store these conditions / time on page? I understand I'll probably write a cookie so it only alerts the visitor once. I do like the idea of prompting them after they've been on the site for a certain period of time. fyi. My goal is simple. People may have not noticed the information they need so I want to indicate such. I just want to provide a little alert box or something to redirect them if they choose.
weinerschizel wrote:
What variables store these conditions / time on page?
None. You have to code that yourself. You could start a timer when the page loads, show your message when the timer expires, or pass on the time when you leave to the next page of your site, so it can load its timer with the value carried over (through cookie or URL). And I haven't actually done any of this, as I don't like such reminders at all... :)
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
I'm writing a simple piece of code to display a popup when somebody leaves my wordpress blog. It will simply ask if they wanted to register for my next open house before they leave the website. Here's what I have...
<script language="JavaScript">
window.onbeforeunload = confirmExit;
function confirmExit()
{
return "Have you registered for my open house tour?";
}
</script>That displays everytime a page is unloaded though... I want to simply check what the next page is and if it doesn't contain my domain then trigger the popup. I found this code but it won't work because it shows the previous pages address when I need to see the next page to loads address.
var s = window.location.href;
var s = window.
return s;Does anybody know how I can grab the next page that will be loaded from the browser? Thanks!