How to Make Your Own URL Shortener with JavaScript in Blogger

How to Make Your Own URL Shortener with JavaScript

MyBacklink86 - How to Make Your Own URL Shortener with My Backlink, JavaScript - In this post I tried to create its own URL shortener using JavaScript code. If before me and you used to use bit.ly, goo.gl and the like, now I am and you will create its own URL shortener. The script that I can share is also called a URL Redirect. URL Redirection or transfer permalink actually been facilitated by a blogger, only limited on our blog, can not lead to other blogs.

If the existing CMS WordPress plugin "Simple URLs", the result will be something like with it, because I was also inspired by this plugin. If my friend do not know, maybe my friend never seen such links http://mybacklink86.blogspot.com/go/fb more or less like the picture. To be more clear, please click the Facebook My Backlink 86 below:

 https://your-link.blogspot.com/go/fb

To make it, save the code above </head> .

Example One

<script language='javascript'>
//<![CDATA[
var key = window.location.href.split("go/")[1].replace("/","")
var urls={
'fb':'https://www.facebook.com/mybacklink86,
'gplus':"https://plus.google.com/+xxxxxx",
'twitter':"https://twitter.com/xxxxxxx",
'blabla':"http://xxxxx.com/",
'blabla':"http://blabla.net",
'blabla':"http://www.blabla.com",
'blabla':"https://www.blabla.us" /* the latter without coma */
}
if(key){
if(urls[key]){
window.location.href=urls[key]
}else{
document.write("'"+key+"' not found :(");
}
}
//]]>
</script>

Example Two

<script language='javascript'>
//<![CDATA[
var key = window.location.href.split("go/")[1].replace("/","")
var urls={
'fb':'https://www.facebook.com/mybacklink86,
'gplus':"https://plus.google.com/+xxxxxx",
'twitter':"https://twitter.com/xxxxxxx",
'blabla':"http://www.blabla.com",
'blabla':"https://www.blabla.us" /* the latter without coma */
}
if(key){
if(urls[key]){
window.location.href=urls[key]
}else{
document.write("'"+key+"' not found :(");
}
}
//]]>
</script>

Example Three

<script language='javascript'>
//<![CDATA[
var key = window.location.href.split("go/")[1].replace("/","")
var urls={
'fb':'https://www.facebook.com/mybacklink86,
'gplus':"https://plus.google.com/+xxxxxx",
'twitter':"https://twitter.com/xxxxxxx" /* the latter without coma */
}
if(key){
if(urls[key]){
window.location.href=urls[key]
}else{ document.write("'"+key+"' not found :(");
}
}
//]]>
</script>

Change / add the link as desired mate. To understand it, when I wrote 'fb':'https://www.facebook.com/mybacklink86' means, when accessing http://your-link.blogspot.com/go/fb will lead to https://www.facebook.com/mybacklink86.