loading...

Sunday, September 26, 2010

bookmarking to Social sites using keyboard shortcuts

Bookmarking to social sites such as twitter,facebook,digg,reddit,stumbleupon etc are becoming more and more.When a reader visits a website ,if the visitor likes the article or content then the visitor wants to bookmark the content or site and would search for the social icons .So what if the visitor can bookmark your site with a keystroke which makes much easy for your unique visitors.Here i will be using javascript to enable this.I will be explaining how to integrate it into your website or blog.


Step1
Find the body tag and add inside  the tag
Add this
onkeypress="bookmark()"
example:<body onkeypress="bookmark()">


Step2
Then Add the following code before the </body>
<script>
function bookmark() 
{

    if (window.event.keyCode ==115 || window.event.keyCode ==83) 
        {window.open('http://www.stumbleupon.com/submit?url='+encodeURIComponent(document.location)+'&amp;title='+encodeURI(document.title)+'')};
    if (window.event.keyCode == 116 || window.event.keyCode ==84) 
        {window.open('http://twitthis.com/twit?url='+encodeURIComponent(document.location)+'&amp;title='+encodeURI(document.title)+'')};
    if (window.event.keyCode == 100 || window.event.keyCode ==68) 
        {window.open('http://digg.com/submit?phase=2&amp;url='+encodeURIComponent(document.location)+'&amp;title='+encodeURI(document.title)+'')};
    if (window.event.keyCode == 106 || window.event.keyCode ==83) 
        {window.open('http://www.facebook.com/share.php?u='+encodeURIComponent(document.location)+'')};
    if (window.event.keyCode == 102 || window.event.keyCode ==70) 
        {window.open('http://www.google.com/bookmarks/mark?op=edit&amp;bkmk='+encodeURIComponent(document.location)+'&amp;title='+encodeURI(document.title)+'')};
    if (window.event.keyCode == 121 || window.event.keyCode ==89) 
        {window.open('http://myweb2.search.yahoo.com/myresults/bookmark?t='+encodeURI(document.title)+'&amp;u='+encodeURIComponent(document.location)+'')};
    if (window.event.keyCode == 114 || window.event.keyCode ==82) 
        {window.open('http://reddit.com/submit?url='+encodeURIComponent(document.location)+'&amp;title='+encodeURI(document.title)+'')};
    if (window.event.keyCode == 103 || window.event.keyCode ==71) 
        {window.open('http://mail.google.com/mail/?view=cm&amp;fs=1&amp;su='+encodeURI(document.title)+'&body='+encodeURIComponent(document.location)+'')};
    if (window.event.keyCode == 119 || window.event.keyCode ==87) 
        {window.open('https://favorites.live.com/quickadd.aspx?url='+encodeURIComponent(document.location)+'&amp;title='+encodeURI(document.title)+'')};
    if (window.event.keyCode == 98 || window.event.keyCode ==66) 
        {window.open('https://favorites.live.com/quickadd.aspx?url='+encodeURIComponent(document.location)+'&amp;title='+encodeURI(document.title)+'')};
   
}
</script>

Thats it!
Now keystrokes
Twitter- t or T
Digg- d or D
Stumpleupon- s or S
Facebook-f or F
Reddit-r or R
Google-g or G
Yahoo-y or Y
Windows live-w or W

For live Action Try hitting the Keystroke on this page

You can add more to the above script.Any problem ask me .

No comments:

Post a Comment

fuzionpro Headline

fuzionpro