jQuery Plugin For URL Shortener with Google API - URL Shortener
File Size: | 5.96KB |
---|---|
Views Total: | 2480 |
Last Update: | |
Publish Date: | |
Official Website: | Go to website |
License: | MIT |

URL Shortener is a jQuery plugin that allows you to shorten a URL, get long url from a short url or get short url info using Google URL Shortener API.
Basic Usage:
1. Include the latest version of jQuery javascript library from google CDN
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
2. Include jQuery URL Shortener Plugin after jQuery library
<script src="jquery.urlshortener.js" type="text/javascript"></script>
3. Create the html to shorten a URL
<input type='text' id='longUrl' value='https://www.jqueryscript.net/' /> <input type="button" id="shortIt" value="Short It" />
4. The javascript
<script type="text/javascript"> $(document).ready(function() { //jQuery.urlShortener.settings.apiKey='AIzaSyDoE0akrBvl1f3IIRLpuXpVBDsxTfa4ceg'; $("#shortIt").click(function() { $("#shortUrlInfo").html("<img src='images/loading.gif'/>"); var longUrlLink =$("#longUrl").val(); shortUrl = jQuery.urlShortener({longUrl:longUrlLink}); $("#shortUrlInfo").html(shortUrl); }); }); </script>
Change log:
v1.0.1 (2013-10-25)
- Used Google API Client
This awesome jQuery plugin is developed by hayageek. For more Advanced Usages, please check the demo page or visit the official website.