How To Brand Your Ain Url Shortener Amongst Javascript Inward Blogger
How Custom URL Shortener Works?
We volition live on using a script to practise our ain URL shortening service. This script tin besides live on termed every bit "Simple Redirects". Just similar WordPress, y'all practise links that volition redirect y'all to external pages or domains. Unlike Blogger Custom Redirects, which does non allows y'all to redirect to other domains, they exclusively redirects to internal pages of your blog.Default URL: www.facebook.com/mybloggerlab
Custom Branded Short URL: www.mybloggerlab.com/go/fb
Take a await at the inward a higher house links to sympathize how this script volition work. If y'all volition become to www.mybloggerlab.com/go/fb it volition accept y'all to the Facebook page of MyBloggerLab. Similarly y'all tin practise unlimited brusk URLs together with Redirects using this script.
How to Make Your Own URL Shortener amongst JavaScript:
To install URL Shortener script inward your Blogger site, delight follow the below instructions correctly:
- Go to Blogger >> Template >> Edit HTML.
- Now inward the template codes, search for </head> tag together with only inward a higher house it glue the next JavaScript code:
<script language='javascript'>
//MyBloggerLab URL Shorener
//<![CDATA[
var cardinal = window.location.href.split("go/")[1].replace("/","")
var urls={
'fb':'https://www.facebook.com/mybloggerlab',
'gplus':"https://plus.google.com/+mybloggerlab",
'twitter':"https://twitter.com/mybloggerlab",
}
if(key){
if(urls[key]){
window.location.href=urls[key]
}else{
document.write("'"+key+"' non constitute :(");
}
}
//]]>
</script>
Customization:
Now to practise brusk URLs y'all tin uncomplicated build changes to the inward a higher house code. For example, inward the inward a higher house code search for this:
'fb':'https://www.facebook.com/mybloggerlab',
In the inward a higher house code fb is the keyword together with https://www.facebook.com/mybloggerlab is the targeted website or webpage. If nosotros translated the inward a higher house code it agency that when you'll view www.mybloggerlab.com/go/fb it volition accept y'all to https://www.facebook.com/mybloggerlab.
You tin add together to a greater extent than brusk URLs every bit well, for instance if y'all desire to practise a brusk link for y'all Pinterest profile thus the inward a higher house code volition await similar this:
<script language='javascript'>
//MyBloggerLab URL Shorener
//<![CDATA[
var cardinal = window.location.href.split("go/")[1].replace("/","")
var urls={
'fb':'https://www.facebook.com/mybloggerlab',
'gplus':"https://plus.google.com/+mybloggerlab",
'twitter':"https://twitter.com/mybloggerlab",
'pinterest':"https://twitter.com/mybloggerlab",
}
if(key){
if(urls[key]){
window.location.href=urls[key]
}else{
document.write("'"+key+"' non constitute :(");
}
}
//]]>
</script>
3. After customizing the script every bit per your needs, press the "Save Template" push clit on the acme of your screen.
We promise this tutorial has helped y'all inward learning how to build your ain URL shortener inward Blogger. Let us know what are y'all thoughts inward the comments below.
Baca Juga

Post a Comment
Post a Comment