html-redirect
Generate HTML redirection page.
Example
;
example1.html:
(redirect) Click me
API
htmlRedirect(url, [options])
Returns a readable stream of HTML.
Option | Type | Required? | Default |
---|---|---|---|
timeout | number | No | 1 |
title | string | No | |
placeholder | string | No | |
replaceBody | boolean | No | false |
options.timeout
is a timeout for meta-tag redirection. JS redirection will fire instantaneously regardless of the value of this option.
options.title
is the value of <title>
.
options.placeholder
is either the text under default <a>
or the whole <body>
in HTML depending on options.replaceBody
.
htmlRedirect.createStream(url, [options])
Returns a transform stream. Body content → HTML page.
Option | Type | Required? | Default |
---|---|---|---|
timeout | number | No | 1 |
title | string | No |
CLI
Usage: html-redirect [OPTION]... URL
Options:
--title Page title
--placeholder Text under <a> in the page body, or the page body itself
--replace-body If true, --placeholder replaces the whole body of a page
--timeout http-equiv refresh timeout
More examples
Set some options
;
example2.html:
please wait... Your browser does not support redirection. Please click this link.
Replace body
;
example3.html:
please wait... Your browser does not support redirection. Please click this link.
Use it as a transform stream
example4.js:
processstdin ;
Try it in the console:
printf 'Contents from the <b>stdin</b>.' |node example.js
<!DOCTYPE html>
<html>
<head>
<title>(redirect)</title>
<meta http-equiv="refresh" content="1;url=http://example.com/">
<script>window.location.replace("http://example.com/");</script>
</head>
<body>Contents from the <b>stdin</b>.</body>
</html>
Install
npm install html-redirect
License
MIT