Skip to content

Custom Element that redirects to a new URL when an attribute is changed. It's also being listened by Palindrom.

License

Notifications You must be signed in to change notification settings

Palindrom/palindrom-redirect

 
 

Repository files navigation

<palindrom-redirect>

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.

Demo

Check it live!

Install

Install the component using Bower:

$ bower install palindrom-redirect --save

Or download as ZIP.

Usage

  1. Import Web Components' polyfill, if needed:

    <script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
  2. Import Custom Element:

    <link rel="import" href="bower_components/palindrom-redirect/palindrom-redirect.html">
  3. Start using it!

    <palindrom-redirect url=""></palindrom-redirect>

Attributes

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.

Events

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.

Methods

Name Parameters Returns Description
redirect {String} url {String} exact redirect location Performs redirect to given url programmatically

History

For detailed changelog, check Releases.

License

MIT

About

Custom Element that redirects to a new URL when an attribute is changed. It's also being listened by Palindrom.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HTML 91.0%
  • JavaScript 9.0%