Custom Element that redirects to a new URL when an attribute is changed. It can be configured to work using window location or History API.
Install the component using Bower:
$ bower install palindrom-redirect --save
Or download as ZIP.
-
Import Web Components' polyfill, if needed:
<script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
-
Import Custom Element:
<link rel="import" href="bower_components/palindrom-redirect/palindrom-redirect.html">
-
Start using it!
<palindrom-redirect url=""></palindrom-redirect>
Attribute | Options | Default | Description |
---|---|---|---|
url |
String | Destination URL | |
url |
current |
If a string "current" is provided as the URL, the component reloads the page |
|
history |
If attribute history is present, the History API pushState is used instead of window.location |
||
target |
String | _self |
Target where to open the link. Use "_blank" to open in new tab. |
Name | Details | Bubbles | Description |
---|---|---|---|
palindrom-redirect-pushstate |
{url: "/new/path"} |
yes | Triggers every tie history.state is changed by the element. This event is being listened by Palindrom, and triggers updating its state. |
Name | Parameters | Returns | Description |
---|---|---|---|
redirect |
{String} url | {String} exact redirect location | Performs redirect to given url programmatically |
For detailed changelog, check Releases.
MIT