Javascript Alert Alternate with Jquery Message

I am just a student and have no idea about javascript and jquery. I want to declare an adblock script detector. What I found is a piece of code that gives an unpleasant warning message. I want to give an ajaxed message, not the message that appears on the screen.

<script type="text/javascript"> function _enabled() { alert('Hey Dude!!! You are using Adblock on this site? Please disable Adblock or Any other plugin blocking ads. Its the only way we cover the cost of the Servers and Website. Click OK to continue what you were doing'); } function _disabled() { alert('not detected'); } var _abdDetectedFnc = '_enabled'; var _abdNotDetectedFnc = 'disabled'; </script> <script type="text/javascript" src="http://www.adblockdetector.com/script.php"></script> 

By replacing this code, can you help me with an alternative to this code?

 { alert('Hey Dude!!! You are using Adblock on this site? Please disable Adblock or Any other plugin blocking ads. Its the only way we cover the cost of the Servers and Website. Click OK to continue what you were doing'); } 

I came by finding some solutions on how to get it using jquery or jquery-ui, but I don’t know what to put and replace the code here. I tried the sample code from http://m0006.gamecopyworld.com/games/gcw_notice.shtml , which gives a nice Adblock Detect message. But he didn’t work at all. Only this warning message is running on this website.

+4
source share
4 answers

As a very quick alternative, it looks a little better, you can use the jQuery-ui dialog (as Ricky Baby said)

You will also need to include jQuery and jQuery-ui libraries on your page. They can be downloaded from http://jquery.com/download/ and http://jqueryui.com/download/ if you do not already have them.

You can change the text "Hello dude ... etc." whatever you like

 <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css" type="text/css" media="all" /> </head> <body style='height: 100%;'> <script type="text/javascript"> function _enabled() { var html = "<div>Adbloc detected</div>"; var diag = $(html).dialog( { autoOpen: true, modal: true, close: function() { $(this).empty().remove(); }, buttons: { "Close": function() { $(this).dialog("close"); } } }); } function _disabled() { var html = "<div>Adbloc NOT detected</div>"; var diag = $(html).dialog( { autoOpen: true, modal: true, close: function() { $(this).empty().remove(); }, buttons: { "Close": function() { $(this).dialog("close"); } } }); } var _abdDetectedFnc = '_enabled'; var _abdNotDetectedFnc = '_disabled'; </script> <script type="text/javascript" src="http://www.adblockdetector.com/script.php"></script> </body> </html> 

Alternatively, you can simply put a message at the bottom of the screen if you don't want to pop up at all

 <div id='adBlockDetected' style='position: fixed; bottom: 20px; left: 0px; width: 100%; display: none;' >Hey dide .... etc </div> 

Then in the function _enabled ()

 $("#adBlockDetected").css({display: "block" }); 
+4
source

See this question:

Adblock Detection Issues

below, it sets its message to display in a div (which it calls # Ad-One), setting the html attribute.

+2
source

If you want to use jQuery-ui, a dialog box will appear to make the message more enjoyable: http://jqueryui.com/dialog/

However, you also mix your terms - AJAX is the "brand" name for requesting data from a remote terminal using an XMLHTTP object and its associated methods.

+1
source

If all you need is “pretty” alerts, the jQuery user interface is a bit overloaded. I would go with something like Apprise: http://thrivingkings.com/read/Apprise-v2-The-new-and-improved-attractive-alert-alternative-for-jQuery

Using only the default settings:

 <!-- added to head --> <link href="path_to_css/apprise-v2.min.css" rel="stylesheet" type="text/css" /> <script src="path_to_jquery"></script> <script src="path_to_scripts/apprise-v2.min.js"></script> <script> $(function(){ Apprise('hi there'); }); </script> 

receives a message with a nice smooth warning:

enter image description here

Of course, I am also curious about what you are trying to achieve here:

 <script type="text/javascript" src="http://www.adblockdetector.com/script.php"></script> 

If this PHP page is not a JavaScript file, you cannot do this. The src attribute must point to a valid and addressable JavaScript file.

0
source

All Articles