Forum Moderators: open

Message Too Old, No Replies

can u check how long the page is in pixels?

i want to return this to check if im gonna add

         

mecjfl

8:52 pm on Feb 18, 2006 (gmt 0)



another banner from adsense

can this be done?

DrDoc

9:11 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



document.body.scrollHeight :)

mecjfl

12:57 am on Feb 20, 2006 (gmt 0)



what i want to accomplish is this:

if the page is "high" enough (x number pixels), i will put another vertical banner in... if it aint, i wont

simple? =)

DrDoc

2:06 am on Feb 20, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



so ...

...
if(document.body.scrollHeight > ####) {
//code in here to add the banner
}
...

mecjfl

3:39 am on Feb 20, 2006 (gmt 0)



thanks doc...... hmm

woudl anyone be so kind to ask adsense if its allowed i dont see why

ok how would the code that i if look like?

Hobbs

8:57 pm on Feb 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think there is a FireFox extension that does this, investigate it.

joaquin112

10:11 pm on Feb 18, 2006 (gmt 0)

10+ Year Member



Do you mean for PHP?

MyGen

10:11 pm on Feb 18, 2006 (gmt 0)

10+ Year Member



A don't know of an exact function to do so, but a wise idea might be using the file size function in PHP to check the size of the page, obviously compensate for your regular layout code, but if (layout code + content = XYZ) { insert extra ad block } , seems logical enough.

mecjfl

10:48 pm on Feb 18, 2006 (gmt 0)



well i need to use javascript on client side to know exact height so i know if its good to put the second banner on it

anand84

2:16 pm on Feb 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is a very raw way to do this. For the width, make a single row table parallel to your contents with as many columns, each of 20 pixels or so. So when you can make 15 columns that exactly fit your page, you can have the width as 20*15 = 300 pixels.

bumpski

4:47 pm on Feb 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



client scripting

<SCRIPT LANGUAGE=javascript>
<!--
YSizePixels = document.body.clientHeight;
XSizePixels = document.body.clientWidth;
//-->
</SCRIPT>

I think the above does what you want on the client end.

Some references:
[msdn.microsoft.com...]
[developer.mozilla.org...]

Look for the "document" and "body" elements.

bumpski

4:54 pm on Feb 19, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just a follow up.
I still haven't figured out how to conditionalize the Google java scripts without modifying the code as provided. I guess it depends on your definition of modifying.

Does removing the script declarations count? There are other legitimate sites doing more, so I don't know.

I'm simply amazed Google hasn't wrapped a CRC around the code to make it easy to detect any alteration at all.

If you try to put the Adsense code in an IFrame it won't work anymore, (it used too!). I don't think hiding the ads would be a good idea at all. That would break the TOS.

mecjfl

12:58 am on Feb 20, 2006 (gmt 0)



hrm i just want banners on long pages and not banners on short. :((((

DrDoc

6:12 pm on Feb 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Perhaps I may offer two suggestions:

1) You should probably find a JavaScript tutorial somewhere. It is impossible to know exactly what the code would look like without looking at your page and your code. And, we do not allow personal URLs or "do my homework" type posts [WebmasterWorld.com]. So, if you want someone to do it for you, and do not want to take the time to learn a tad about JavaScript, the best option is to take a trip to the Commercial Exchange [webmasterworld.com] forum where you can be sure to find some assistance.

2) Questions about whether this is allowed or not are probably best answered in the AdSense [webmasterworld.com] forum.

:)

As already mentioned by several in this thread, the way this can be accomplished is by using

document.body.scrollHeight
.

Put something like this in the <head> of your document:

<script type="text/javascript">
window.onload = function() {
if(document.body.scrollHeight > ####) {
document.getElementById('ad2').innerHTML = "****";
}
</script>

#### is the height, as determined by you
**** is the code for the second banner

And, at the bottom of your page (or, whever you would like the second ad to appear), add this div:

<div id="ad2"></div>

mecjfl

7:48 pm on Feb 25, 2006 (gmt 0)



" the Commercial Exchange forum"

lol yeh rite and pay you money heheheh

Bernard Marx

11:13 pm on Feb 25, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



..or whoever you choose to hire.

DrDoc

1:19 am on Feb 26, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mecjfl,

The answer has been given in this thread several times already. If that is not sufficient, then perhaps reading up on JavaScript somewhere (there are many great tutorials you can find) would be a great starting point before moving forward.