Guys, not sure what to search for in order to get an answer for my query, so apologies if this has been answered before.

Essentially, on my site i have URL's to external sites. Whenever someone clicks on an URL pointing to an external site I want them to be directed to a temporary holding page (which will contain an advert) , after a five second delay the holding page will be refreshed so that it displays the content of the external URL.

Does anyone have any pointers on how this can be done?

I know i could use a meta-tag to do the refresh, but not sure how to get people to go to the holding page.

Any help would be much appreciated.

Dani AI

Generated

For a reliable, user-friendly result: send outgoing clicks through a short interstitial on your own domain instead of trying to trap browser unload events. That gives you a stable place to show the advert, count down five seconds, log the click, and then send the visitor on — and it avoids popup blockers and the inconsistent behavior hinted at.

Change outgoing links so they point to a local redirect endpoint (either with an encoded URL or, safer, with a server-side ID). A simple pattern:

<a href="/out?url=https%3A%2F%2Fexample.com" rel="nofollow noreferrer">Visit external site</a>

The /out page should:

  • Decode the destination, validate it, and refuse unexpected schemes.
  • Prefer storing destinations by ID on the server (e.g. /out?id=123) or sign the url parameter so users cannot tamper with it.
  • Show your ad and a visible countdown, then use a short JS timer to location.href = target. Include a clickable “Continue” and a <noscript> fallback so users without JS can proceed.

Security, SEO and UX notes:

  • Protect against open-redirect attacks — see OWASP on unvalidated redirects and forwards: .
  • Mark the interstitial noindex, nofollow and use rel="nofollow noreferrer noopener" on links to avoid SEO or security issues (see MDN on the anchor element: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a).
  • Check ad-network policies and keep the experience quick and transparent — long or unexpected redirects harm conversion and can annoy users.

Checklist: route via an interstitial, validate destinations (whitelist or server-side IDs), show a clear countdown + skip option, add noindex, and log the click for analytics. This is more robust than relying on client unload handlers.

Recommended Answers

All 2 Replies

I'm not sure you can accomplish everything you want to do, but you should check out the JavaScript 'onUnload' event handler. It is placed in the body tag and is intended to run a JavaScript routine when someone tries to leave a page. I've seen it used for pop-ups.

Obviously, it will only work when a user has JavaScript enabled.

Hope that helps.

Atleast its an idea :)

I'll have a look into that.

Cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.