Forum Moderators: martinibuster

Message Too Old, No Replies

Need help with Javascript

I want to stop showing Adsense ads on sertain pages

         

photo200

5:17 pm on Sep 9, 2005 (gmt 0)

10+ Year Member



Hi. Browsing for 2 hours and no success.

I have no knowledge of javascript at all.
Please, help me.

On my site there is
index.php?cat=widget

I want to stop showing Adsense ads if
widget actually "Red Widget" for instance.

I know how to do it in .php
But the problem is in templates and changes in php will mess up everything. I need to make it in javascript.

Thanks.
If it will work - I'll share why exactly I need it.
I had some observation.

MyGen

6:10 pm on Sep 9, 2005 (gmt 0)

10+ Year Member



Surely it would be easier to do it in PHP?

<? if ($_GET['cat']!== 'value') { $showad = 0; } else { $showad = 1; }?>

Then just before the adsense code:

<? if ($showad == 1) }?> All the adsense code here <? }?>

photo200

7:05 pm on Sep 9, 2005 (gmt 0)

10+ Year Member



Thanks a lot.

I've tried this.

No luck.
I can't transfer a variable "cat" from template (which is .html) into ad.php?cat="value".

Will have a look tomorrow.
But if someone knows how to solve it in javascript -
I would be really appreciated.

jomaxx

7:47 pm on Sep 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can't do it in Javascript without changing Google's Javascript code which is not allowed.

I'm sure there's some way in PHP.

[edited by: jomaxx at 7:49 pm (utc) on Sep. 9, 2005]

Iguana

7:47 pm on Sep 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I used to control whether my Adsense Ads were shown on certain pages . But at least a year ago the TOS banned any change to the Javascript and insisted it was pasted "as is" onto the page. i think PHP or some other Server-side language is the only choise here.

photo200

7:51 pm on Sep 9, 2005 (gmt 0)

10+ Year Member



Thanks again.

As I said - I can do it but with lot of side effects
because of my .php was written by someone else. And it is full of templates and all these stuff.

I just thought that it would be easier with javascript.

RonPK

8:02 pm on Sep 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<script type="text/javascript">
if (location.search.indexOf('cat=redwidget') > -1) {
document.write('<style type="text/css">div#ASdiv {display: none;}<\/style>');
}
</script>
.
.
.
<div id="ASdiv">
// AdSense code here
</div>

There is a specialized forum for javascript related subjects [webmasterworld.com], by the way.

photo200

8:29 pm on Sep 9, 2005 (gmt 0)

10+ Year Member



Wooyauuu!

It works,
but indeed it is not exactly what I needed ( I just realised it now only ).

Adsense code is still on the page it is just not showing. And it will be anyhow if it is Browser side of scripts. I need to go from server.

Thanks to all of You.
Tomorrow will try to figure out how to do it in PHP.