Follow Me on Google News Follow Now!

How To Disable Right Click With Alert Notification

Hello Friends! Welcome To Adatun, I mean Gyanitheme's Blog. The right click function when opening a browser is usually used to copy and view page sources from a blog/website. In addition to right-clicking, there are also those who use the keyboard to do this, such as ctrl+U and ctrl C

So, Today in this post I will show you How To Disable Right Click With Alert Notification. And if you are using pre code box then you can add notification of Copied To Clipboard as popup toast notification. This Alert Notification is made with the help of HTML, CSS, JS. 

Benefits :-

  • Good User Experience
  • Avoid From Copy Paste
  • Disable Context Menu
  • Popup Copied To Clipboard Message
  • Disable View Source By CTRL+U

Demo :-

If you want to see the demo of this popup notification, then by clicking on the demo button given below, you will reach the demo website and there you have to right click or press CTRL+U.


If you want to know about How Can I Add Pop Up Toast Notification in Blogger Website.Then read the full article. Don't skip any steps. So Let's start.

Warning!
Before we start adding codes in XML, I will recommend you to take a Backup of your current theme. By chance if any problem occurs, you can restore it later.

How To Disable Right Click ( Context Menu ) In Blogger Website :-

Step 1 :- First of All. You Need To Log in With Your Blogger Account.
Step 2 :- Now Go To Theme/Template Section.
Step 3 :- Now Click on Edit HTML.
Step 4 :- Now Find ]]></b:skin> Tag in Your Theme.

Note!
To search anything in blogger template section press Ctrl+F and then type term to search and press enter.

Step 5 :- Now copy the code provided below and paste it before the tag which we have searched in step 4.
/* Righ Click Alert by Adatun */
.alert{position:fixed;bottom:20px;right:20px;z-index:999999;width:auto;max-width:400px;margin:0 0 0 20px;background-color:rgba(0,0,0,.7);border-radius:4px;color:#fff;box-shadow:1px 7px 14px -5px rgba(0,0,0,.2);border-left:3px solid red}
.alert-main{text-align:left;padding:20px;padding-left:30px;padding-right:20px}
.c-timebar{width:100%;height:2px;position:absolute;bottom:0;left:0}
.c-timebar__remaining{width:100%;height:100%;position:absolute;left:0;top:0;border-radius:5px;background:rgba(255,255,255,1);z-index:2;transform-origin:0 0;animation:timebar_progress;animation-duration:5s;animation-timing-function:linear}
.alert:hover .c-timebar__remaining{animation-play-state:paused}@keyframes timebar_progress{from{transform:scaleX(1)}to{transform:scaleX(0);background:transparent}}
Step 6 :- Now copy the code provided below and paste it before the <body> tag or after the </head> tag.
<div id='Alert-Parent'/>
Step 7 :- After that copy the js code provided below and paste it above the </body> tag.
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js' type='text/javascript'/>
<script type='text/javascript'>
//<![CDATA[
/*! Context Menu Alert */
function alert(content){var a="<div class='alert'><span class='alert-close' onclick='this.parentElement.style.display=&quot;none&quot;'></span><div class='alert-main'><span class='alert-icon'></span><div class='alert-content'>"+content+"</div><div class='c-timebar'><div class='c-timebar__remaining'></div></div></div></div>";$('#Alert-Parent').html(a);var countdown;$(".alert").show(resetCountdown).mousemove(resetCountdown);function resetCountdown(){clearTimeout(countdown);countdown=setTimeout(function(){$('.alert').hide()},5000)}}$("<br/> + <br/>").next('<br/>').hide();
//]]>
</script>
<script type='text/javascript'>
//<![CDATA[
var image_save_msg="You Can Not Save images!",no_menu_msg="Context Menu Disabled!",smessage="Double Click & Long Click is Disabled.",keypressmessage="You Are Not Allowed to Copy Content or View Source";function disableEnterKey(e){var n;if(e.ctrlKey)return 97!=(n=window.event?window.event.keyCode:e.which)&&73!=n&&99!=n&&120!=n&&26!=n&&85!=n&&83!=n&&43!=n||(alert(keypressmessage),!1)}function disable_copy(e){var n=e.target.nodeName,o=/Safari/.test(navigator.userAgent)&&/Apple Computer/.test(navigator.vendor);if("TEXT"!=(n=n.toUpperCase())&&"TEXTAREA"!=n&&"INPUT"!=n&&"PASSWORD"!=n&&"SELECT"!=n&&"OPTION"!=n&&"EMBED"!=n)return""!==smessage&&2==e.detail&&alert(smessage),!!o}function disable_copy_ie(){var e=window.event.srcElement.nodeName;return"IMG"==(e=e.toUpperCase())?(alert(image_save_msg),!1):("TEXT"==e||"TEXTAREA"==e||"INPUT"==e||"PASSWORD"==e||"SELECT"==e||"OPTION"==e||"EMBED"==e)&&void 0}function reEnable(){return!0}function disableSelection(e){void 0!==e.onselectstart?e.onselectstart=disable_copy_ie:void 0!==e.style.MozUserSelect?e.style.MozUserSelect="none":e.onmousedown=function(){return!1},e.style.cursor="default"}document.onkeydown=disableEnterKey,document.onselectstart=disable_copy_ie,-1==navigator.userAgent.indexOf("MSIE")&&(document.onmousedown=disable_copy,document.onclick=reEnable),window.onload=function(){disableSelection(document.body)},document.ondragstart=function(){return!1},document.oncontextmenu=function(e){return alert(no_menu_msg),!1},function e(){try{!function e(n){1===(""+n/n).length&&0!==n||function(){}.constructor("debugger")(),e(++n)}(0)}catch(n){setTimeout(e,5e3)}}(),$("img").mousedown(function(){return!1}),1!=navigator.onLine&&(window.location.href="#");jQuery.fn.selectText=function(){this.find("input").each(function(){0!=$(this).prev().length&&$(this).prev().hasClass("p_copy")||$('<p class="p_copy" style="position: absolute; z-index: -1;"></p>').insertBefore($(this)),$(this).prev().html($(this).val())});var e,t=document,o=this[0];console.log(this,o),t.body.createTextRange?((e=document.body.createTextRange()).moveToElementText(o),e.select(),document.execCommand("copy")):window.getSelection&&(t=window.getSelection(),(e=document.createRange()).selectNodeContents(o),t.removeAllRanges(),t.addRange(e),document.execCommand("copy"))},$("pre, code, mark").on("click",function(e){var t=$(this);$(t).selectText(),e.preventDefault(),alert("Your Text is Successfully Copied to Clipboard")});
//]]>
</script>

Note!
You can edit marked text as your wish.

Step 8 :- Now don't forget to click on save button. finished.

Conclusion

In this post I have shared How To Disable Right Click With Alert Notification. I hope this tutorial will be very useful for you and your blog. Thank you for visiting our website.

If you face any problems and errors then put your comments in below comments section with your problems.

Getting Info...
Adatun Provides Blogger Tips, Seo Tips, Blogging Tips, Adsense Tips, Best Blogger Template Updates, Html, Css, Javascript and More.

Blog: Adatun Blog

Post a Comment