1.0.1 • Published 11 months ago

@giftomatic/popunder v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Giftomatic Popunder

A lightweight JavaScript module that opens two links simultaneously: one in a new tab and another as a 'popunder' in the original tab after a configurable delay. If the user returns to the original tab before redirection, the event is canceled.

Installation

npm i @giftomatic/popunder

Usage

import * as Popunder from "@giftomatic/popunder";
Popunder.install();

Example

<!-- Simple link -->
<a
  href="https://www.google.com"
  target="_blank"
  data-popunder="https://www.bing.com"
>
  Google
</a>

<!-- Link with delay configured -->
<a
  href="https://www.amazon.co.uk"
  target="_blank"
  data-popunder="https://www.amazon.com"
  data-refresh-delay="5"
>
  Amazon
</a>

Or see the full example.

Install through jsDelivr

import * as Popunder from "https://cdn.jsdelivr.net/npm/@giftomatic/popunder@1.0.0/dist/esm/popunder.js";

Configuration

OptionTypeRequiredDescription
data-popunderURLYesURL to open as a popunder
data-refresh-delayNumberNoDelay in seconds before opening the popunder, default is 3s