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 juicy-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/juicy-redirect/juicy-redirect.html">
-
Start using it!
<link is="juicy-redirect" url=""></link>
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 |
---|---|---|---|
juicy-redirect-pushstate |
{url: "/new/path"} |
yes | Triggers every tie history.state is changed by the element |
Name | Parameters | Returns | Description |
---|---|---|---|
redirect |
{String} url | {String} exact redirect location | Performs redirect to given url programmatically |
For detailed changelog, check Releases.
MIT