How to Redirect Blog page While Press CTRL+U with JavaScript

Prevent users to view your Blog Source Code while use CTRL+U by Redirect to another page

protect page source

When we visit a Blog page then generally we use Mouse for doing and managing the task on Browser.  But apart from this there are many keyboard shortcut available for execute the task on browser. Those shortcut functions have added to make browser user friendly.

But now a day’s Content and design theft become very active. And they often use CTRL+U key from keyboard for viewing the page source. Even you have disabled right click function on your Blog but still your contents are copying by others. There are many ways we can manipulate our Blog and protect from content theft. But disabling certain keyboard shortcut is necessary for protecting our Blog content from content thief. Among various keyboard shortcut CTRL+U is very important, because easily user can see page’s source code by using this keyboard shortcut.

But we can disable it different ways. However simply disabling is monotonous process. But we can display a specific warning page or redirect to another Blog page by using javaScript. Previously I have shared about disabling CTRL+U you with simple JavaScript.

How to Disable CTRL+U by Simple JavaScript?

By following below tutorial you can simply disable right click.

Step 1 Go to your Blogger Account and Login to your Blogger Account.

Step 2 Click on ->Template ->Edit HTML

Step 3 And locate by pressing Ctrl+F (Windows) or CMD+F (Mac)

Step 4 And copy the below script and paste it above/before 

<script type="text/javascript">
document.onkeydown = function (cc) {
if(cc.which == 85){
return false;

Step 5 Finally hit the Save template

How to Redirect Blog page While Press CTRL+U with JavaScript?

By using above script you can simple disable the right click. But now I will show you how to add a redirect effect while press CTRL+U from keyboard. After adding this script in Blogger template, when a user use CTRL+U to view source code then s/he will be automatically redirect to specific page. You can set any specific page according to your desire.

Step 1 Go to your Blogger Account and Login to your Blogger Account.

Step 2 Click on ->Template ->Edit HTML

Step 3 And locate by pressing Ctrl+F (Windows) or CMD+F (Mac)

Step 4 And copy the below script and paste it above/before 

<script type='text/javascript'>
shortcut={all_shortcuts:{},add:function(a,b,c){var d={type:"keydown",propagate:!1,disable_in_input:!1,target:document,keycode:!1};if(c)for(var e in d)"undefined"==typeof c[e]&&(c[e]=d[e]);else c=d;,"string"==typeof,a=a.toLowerCase(),e=function(d){d=d||window.event;if(c.disable_in_input){var e;,3==e.nodeType&&(e=e.parentNode);if("INPUT"==e.tagName||"TEXTAREA"==e.tagName)return}d.keyCode?code=d.keyCode:d.which&&(code=d.which),e=String.fromCharCode(code).toLowerCase(),188==code&&(e=","),190==code&&(e=".");var f=a.split("+"),g=0,h={"`":"~",1:"!",2:"@",3:"#",4:"$",5:"%",6:"^",7:"&",8:"*",9:"(",0:")","-":"_","=":"+",";":":","'":'"',",":"<",".":">","/":"?","\\":"|"},i={esc:27,escape:27,tab:9,space:32,"return":13,enter:13,backspace:8,scrolllock:145,scroll_lock:145,scroll:145,capslock:20,caps_lock:20,caps:20,numlock:144,num_lock:144,num:144,pause:19,"break":19,insert:45,home:36,"delete":46,end:35,pageup:33,page_up:33,pu:33,pagedown:34,page_down:34,pd:34,left:37,up:38,right:39,down:40,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123},j=!1,l=!1,m=!1,n=!1,o=!1,p=!1,q=!1,r=!1;d.ctrlKey&&(n=!0),d.shiftKey&&(l=!0),d.altKey&&(p=!0),d.metaKey&&(r=!0);for(var s=0;k=f[s],s<f.length;s++)"ctrl"==k||"control"==k?(g++,m=!0):"shift"==k?(g++,j=!0):"alt"==k?(g++,o=!0):"meta"==k?(g++,q=!0):1<k.length?i[k]==code&&g++:c.keycode?c.keycode==code&&g++:e==k?g++:h[e]&&d.shiftKey&&(e=h[e],e==k&&g++);if(g==f.length&&n==m&&l==j&&p==o&&r==q&&(b(d),!c.propagate))return d.cancelBubble=!0,d.returnValue=!1,d.stopPropagation&&(d.stopPropagation(),d.preventDefault()),!1},this.all_shortcuts[a]={callback:e,target:d,event:c.type},d.addEventListener?d.addEventListener(c.type,e,!1):d.attachEvent?d.attachEvent("on"+c.type,e):d["on"+c.type]=e},remove:function(a){var a=a.toLowerCase(),b=this.all_shortcuts[a];delete this.all_shortcuts[a];if(b){var a=b.event,,b=b.callback;c.detachEvent?c.detachEvent("on"+a,b):c.removeEventListener?c.removeEventListener(a,b,!1):c["on"+a]=!1}}},shortcut.add("Ctrl+U",function(){top.location.href=""});


  • Please replace the with your desired page URL.
Step 5 Finally hit the Save template

In the above code I have set my Blog home page URL and when a user press CTRL+U then s/he will be automatically redirect to My Blog homepage. Similarly if I add any other page URL then they will automatically redirected on that page. This is just like magic. I hope you would love this trick and apply on your Blog to protect your content.
How to Redirect Blog page While Press CTRL+U with JavaScript
4 Stars stars - "How to Redirect Blog page While Press CTRL+U with JavaScript" When we visit a Blog page then generally we use Mouse for doing and managing the task on Brows...

Post a Comment

The Ctrl+Shift+U to Inspect the element, and the 'view-source:' function is still open... :(

Hi Tawsif I know its open. But can you see any specific design by using Ctrl+Shift+U I don't think so. It will just display header and body but can't able to see source code of specific item.

vai, font awesome er code 'fa-th' ei code er icon ti amar nenu bar a home icon er poriborte set korbo kivabe? that means apnar tar moto.

Please visit below URL and get unlimited Icon and use it whatever you would like.

I had already visited this link and from there I got a font awesome code that currently you are using as your home menu icon, but I wanna know how I will change my home menu icon by replacing the font awesome code 'fa-th' like your home menu icon.

You have to change content:"\f015" with Font Awesome icon

Is there any way to hide the source code?

no, but if you minimize CSS and HTML them design thief will become confuse. It will make hard to copy the exact script. :D

Facebook Group Community Disqus Channel Code ConverterHide Code Converter Show EmoticonHide Emoticon

Got questions? Ask ’em below! While we’re here, you might like to give any feedback about this Post, Your comment inspire us to continuous Improvement of This Blog and Contents. Your words are your own, so be nice and helpful if you can. Please, only use your REAL NAME, not your business name or keywords. Using business name or keywords instead of your real name will lead to the comment being deleted. Anonymous commenting is not allowed either. Limit the amount of links submitted in your comment. We accept clean XHTML in comments, but don't overdo it please.

Make sure you tick the Notify Me box below the comment form to be notified of follow up comments and replies. Thank you for commenting

Contact Form


Email *

Message *