Skip to content
This repository has been archived by the owner on Aug 2, 2018. It is now read-only.
/ juicy-redirect Public archive

DEPRECATED! Custom Element that redirects to a new URL when an attribute is changed

License

Notifications You must be signed in to change notification settings

Juicy/juicy-redirect

Repository files navigation

⚠️ This element is DEPRECATED. The development of a more specialised version continues in palindrom-redirect

<link is="juicy-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 juicy-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/juicy-redirect/juicy-redirect.html">
  3. Start using it!

    <link is="juicy-redirect" url=""></link>

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
juicy-redirect-pushstate {url: "/new/path"} yes Triggers every tie history.state is changed by the element

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