admin管理员组文章数量:1355671
I am just a learner and don't have clue about javascript and jquery. What I want to ad an adblock detector script. What I found is this piece of code which gives a nasty alert message. What I want is to give an ajaxed message just not a message popping out of 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=".php"></script>
Replacing this code can you please help me with an alternate 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 along finding some solutions about getting it with jquery or jquery-ui but don't have the knowledge of what to put here and replacing the code. I tried code example from .shtml which gives a nice friendly Adblock Detect message. But it wasn't working at all. Only this Alert Message is working on my website.
I am just a learner and don't have clue about javascript and jquery. What I want to ad an adblock detector script. What I found is this piece of code which gives a nasty alert message. What I want is to give an ajaxed message just not a message popping out of 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./script.php"></script>
Replacing this code can you please help me with an alternate 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 along finding some solutions about getting it with jquery or jquery-ui but don't have the knowledge of what to put here and replacing the code. I tried code example from http://m0006.gamecopyworld./games/gcw_notice.shtml which gives a nice friendly Adblock Detect message. But it wasn't working at all. Only this Alert Message is working on my website.
Share Improve this question asked Feb 5, 2013 at 8:47 itsWrongGuyitsWrongGuy 1262 silver badges9 bronze badges 2- What does Ajax have to do with showing an error message? Did you want the message to be from a remote call to your server? – Tieson T. Commented Feb 5, 2013 at 8:51
- I told in the start, I am just a learner or you can say beginner. Sorry I used Ajaxed – itsWrongGuy Commented Feb 5, 2013 at 10:41
4 Answers
Reset to default 4As a very quick alternative, that looks a bit nicer you can use a jQuery-ui dialog (as Ricky Baby said)
You will also need to include the jQuery and jQuery-ui libraries in your page. These can be downloaded from http://jquery./download/ and http://jqueryui./download/, if you haven't got them already.
You can change the "Hey dude ...... etc" text to what ever you like
<html>
<head>
<script src="//ajax.googleapis./ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//ajax.googleapis./ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis./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./script.php"></script>
</body>
</html>
Alternatively you could just put a message at the bottom of the screen if you didn't want a 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 _enabled() function
$("#adBlockDetected").css({display: "block" });
See this question:
Problems with Adblock detecting
at the bottom, he sets his message to display in a div ( which he calls #Ad-One ) by setting the html attribute.
If you want to use JQuery-ui there is the dialog option to make the message box more pretty see: http://jqueryui./dialog/
However you are also getting your terms mixed up - AJAX - is a "brand" name for requesting data from the remote sever using the XMLHTTP object and related techniques.
If all you need is "pretty" alerts, jQuery UI is a bit of an overkill. I'd go with something like Apprise: http://thrivingkings./read/Apprise-v2-The-new-and-improved-attractive-alert-alternative-for-jQuery
Using nothing but 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>
gets you a pretty slick alert message:
Of course, I'm also curious as to what you're trying to achieve here:
<script type="text/javascript" src="http://www.adblockdetector./script.php"></script>
Unless that PHP page is actually a JavaScript file, you can't do that. The src
attribute needs to point to a valid and addressable JavaScript file.
本文标签: Javascript Alert Alternate with Jquery MessageStack Overflow
版权声明:本文标题:Javascript Alert Alternate with Jquery Message - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743989783a2571923.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论