google+javascriptbanktwitter@js_bankfacebook@jsbankrss@jsbank






Comment faire pour créer Perfect Exit fenêtre Popup Tous les types de popup sont mauvais?


�tiquette: Perfect, Exit, Fenêtre Popup, visiteur, Avis, ressources

Gratuit iPage h�bergement Web pour la premi�re ann�e MOMENT



Si vous �tes toujours � la recherche d'un fournisseur d'h�bergement Web fiable avec des tarifs abordables, pourquoi vous ne prenez pas un peu de temps pour essayer iPage, seulement avec $1.89/month, inclus $500+ Cr�dits suppl�mentaires gratuites pour le paiement de 24 mois ($45)?

Plus de 1.000.000 de clients + existisng peuvent pas avoir tort, vraiment vous n'�tes pas aussi! Plus important encore, lorsque vous enregistrez l'h�bergement web � iPage gr�ce � notre lien, nous allons �tre heureux de renvoyer un plein remboursement. C'est g�nial! Vous devriez essayer iPage h�bergement web GRATUITEMENT maintenant! Et contactez-nous pour tout ce que vous devez savoir sur iPage.
Essayez iPage GRATUIT premi�re ann�e MOMENT

All popups are bad news, right? Nothing gets rid of visitors faster than a crappy ad for casinoviagraporn getting in their face.

But what about visitors that found your site through a search engine, spend 5 seconds on 1 page of your site & then press the back button?

They didn't find what they want.
They aren't coming back.
Don't they deserve some popup love?

Seriously, you have (most likely) lost these visitors for good anyway, so showing them a popup won't make much difference to your visitor retention.

So how do you do it?
The key is the javascript event onUnload. This fires when a page is exited, whether by navigating out via a link, pressing the back button or closing the browser. The problem is, it fires every time a page unloads - and we only want a popup when the visitor leaves your site (not every time they navigate to a new page on your site).

Over at consolescripts.com they describe a solution which involves adding an onClick event to every internal link. The onClick event effectively blocks the popup from firing within the onUnload event.

Its a good solution, but finding every internal link within a decent sized site is a nightmare. So we need an automatic way of adding the onClick event to internal links, and it must not overwrite any existing onClick events we have already set up (unobtrusive javascript).

Check this out:


var Page_Enter;
var TimeLimit=20;
var Page_ShowPopOnExit=false;
var MySiteDomain='YOURSITE.COM';

function XBrowserAddHandlerPops(target,eventName,handlerName) {
  if ( target.addEventListener ) {
    target.addEventListener(eventName, function(e){target[handlerName](e);}, false);
  } else if ( target.attachEvent ) {
    target.attachEvent("on" + eventName, function(e){target[handlerName](e);});
  } else {
    var originalHandler = target["on" + eventName];
    if ( originalHandler ) {
      target["on" + eventName] = function(e){originalHandler(e);target[handlerName](e);};
    } else {
      target["on" + eventName] = target[handlerName];
    }
  }
}

function InternalLink() {
	Page_ShowPopOnExit = false;
}

function PageEnter() {
   Page_Enter=new Date();
}

function SiteExit() {
   var time_dif;
   var Page_Exit=new Date();
   time_dif=(Page_Exit.getTime()-Page_Enter.getTime())/1000;
   time_dif=Math.round(time_dif);
   if (time_dif<=TimeLimit && Page_ShowPopOnExit==true)
	{
	alert('Here is your popup!');
	}
}

function LinkConvert()
{
var href;
	var anchors = document.getElementsByTagName('a');

	for(var y=0; y<anchors.length; y++)
	{
		href = anchors[y].href.toLowerCase();
		if (!(href.indexOf("http://")!=-1 && href.indexOf(MySiteDomain)==-1))
			{
			anchors[y].clickhandler=InternalLink
			XBrowserAddHandlerPops(anchors[y],"click","clickhandler");
			}
	}
}

XBrowserAddHandlerPops(window,"load","PageEnter");
XBrowserAddHandlerPops(window,"load","LinkConvert");
XBrowserAddHandlerPops(window,"unload","SiteExit");
Page_ShowPopOnExit=true;

Save this as popup.js

The javascript does a few things.

  1. As soon as the page is finished loading a copy of the time is stored, so we can tell how long they have been on the page.
  2. All internal links have an onClick event handler added. An internal link is determined as one is missing 'http://' (internal relative links do not have the http:// ) and your domain name in the href. Note: If you are using javascript links for internal navigation then this method will not work. However, it should be easy to add the 'Page_ShowPopOnExit = false;' to your javascript link code.
  3. When the page unloads 2 checks are done; Has the person left the page within XX seconds? (if they stay 5 minutes then perhaps they liked your site, so no popup for them). Is the visitor following an internal link? If the answers are Yes & No respectively, then show them a pop.

Great, but if we just add this .js file to every page on our site then even people who directly type in our URL can be shown pops. These are the hardest of our hardcore fans, and should never get a pop. Also, I only want to show pops to people that hit my site from a search engine & immediately leave - if they visit more than 1 page then no pop for them.

So we need to inspect the Referrer, and check that they are coming from a search engine. I'm going to do this server side so I can cut down on my page size if the visitor is not pop-worthy.

In ASP.Net (put it in the page.load event):


Dim sPageReferrer As String = ""
If Not (Request.UrlReferrer Is Nothing) Then
    sPageReferrer = LCase(Request.UrlReferrer.ToString)
End If
If InStr(sPageReferrer, "google.com") > 0 Or InStr(sPageReferrer, "yahoo.com") > 0 Or InStr(sPageReferrer, "live.com") > 0 Then
    RegisterClientScriptBlock("PopUnder", "<script src='/javascript/article/How_to_create_Perfect_Exit_Window_Popup.php/includes/popunder.js' type='text/javascript'></script>")
End If

If you wanted to do this in the .js file, then just change the last bit of popup.js to:


var href = document.referrer.toLowerCase();
if (href.indexOf("google.com")!=-1 || href.indexOf("yahoo.com")!=-1 || href.indexOf("live.com")!=-1)
	{
	XBrowserAddHandlerPops(window,"load","PageEnter");
	XBrowserAddHandlerPops(window,"load","LinkConvert");
	XBrowserAddHandlerPops(window,"unload","SiteExit");
	Page_ShowPopOnExit=true;
	}


AIVideo-App.com
Générez vos vidéos d'entreprise par l'IA avec la voix ou simplement du texte

chatGPTaz.com
Parlez à ChatGPT dans votre langue maternelle

AppAIVidéo
Votre première application vidéo AI GRATUITE

Deepfake Video
Deepfake AI Video Maker

Deepfake
Deepfake AI Video Maker

AI Deep Fake
Deepfake AI Video Maker

AIvidio
AI Video Mobile Solutions

AIvideos
AI Video Platform & Solutions

AIvedio
AI Video App Maker

Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT

Faceswap AI en ligne
Échangez des visages, des vidéos, des photos et des GIF instantanément avec de puissants outils d'IA - Faceswap AI Online GRATUIT

Temu gratuit 500 $ pour les nouveaux utilisateurs
Claim Free Temu $500 Credit via Affiliate & Influencer Program

Crédits publicitaires TikTok gratuits
Maîtrisez les publicités TikTok pour le marketing de votre entreprise

Dall-E-OpenAI.com
Générez automatiquement des images créatives avec l'IA

chatGPT4.win
Parlez à ChatGPT dans votre langue maternelle

Premier produit d'intelligence artificielle d'Elon Musk - Grok/UN.com
Parlez au chatbot Grok AI dans votre langue

Outily.win
Centre d'outils ouvert et gratuit, utilisable par tous et pour tous, avec des centaines d'outils

GateIO.gomymobi.com
Airdrops gratuits à réclamer et à partager jusqu'à 150 000 $ par projet

iPhoneKer.com
Économisez jusqu'à 630 $ à l'achat d'un nouvel iPhone 16

Acheter le robot Tesla Optimus
Commandez votre robot Tesla Bot : Optimus Gen 2 dès aujourd'hui pour moins de 20 000 $

JavaScript par jour


Google Safe Browsing McAfee SiteAdvisor Norton SafeWeb Dr.Web