-1

I was implementing anti-adblock on my site, since my bitcoin faucet runs by ads. The code I used to see if there is adblock on the clients browser was this: (I do have query if needed)

function TestPage() {
if ($('.advertisement').height() == 0)
var advertisement = "true";
}
$(TestPage);

Then I used this to see if the advertisement variable existed... (if it does then adblock is RUNNING on the clients browser.

<script type="text/javascript">
try {
if(advertisement) {
alert("EXISTS!");
}
} catch(e) {}
</script>

Now what i need it to do is to add disabled="" to my button if the advertisement variable exists... Like this

<input type="submit" name="faucet" disabled="" class="btn btn-default" value="Send">

I am a complete noob at javascript, and I need help doing this... Thanks!

I am slightly confused as to where to put the javascript. I have put the javascript in the head for now...

user2760233
  • 11
  • 1
  • 6

1 Answers1

0

Try to use prop(),

var prop=advertisement ? false : true;
$('input[name="faucet"]').prop('disabled', prop);

Full Code

HTML

<input type="submit" name="faucet" disabled="" class="btn btn-default" value="Send">
<div class="advertisement"></div>

SCRIPT

var advertisement=false;
function TestPage() {
   if ($('.advertisement').height() == 0)
      advertisement = true;
}
$(TestPage);
var prop=advertisement ? false : true;
$('input[name="faucet"]').prop('disabled', prop);

Fiddle http://jsfiddle.net/W2ETd/

Rohan Kumar
  • 40,431
  • 11
  • 76
  • 106
  • like this? http://pastie.org/private/fzbqtrmd2tareu50ncjyaw It does not work :( BTW if it matters, it is all located in the head of the html... – user2760233 Sep 13 '13 at 04:52
  • I changed the first line "var advertisement=true;" just to test it out, and it didnt work :( Code: http://puu.sh/4pZex.png Thats the head and thats the button http://puu.sh/4pZiv.png The thing just stays as disabled... – user2760233 Sep 13 '13 at 05:06
  • I have tried the js fiddle, and i just changed it to false and true for testing purposes, and no matter what it stays as disabled... – user2760233 Sep 13 '13 at 23:01