Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Adsense in javascript file
Old 03-24-2007, 04:38 PM Re: Adsense in javascript file
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
BJ,
I think the problem might be on the google side, when they generate the iframe to contain the ads.

You might have overlooked it, but if you just want to add a border around the ads, why don't you use the google method ?
there is a "google_border_color" line in the js, which you can set to an #rrggbb value, and create your border that way.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
 
Register now for full access!
Old 03-24-2007, 05:01 PM Re: Adsense in javascript file
bj_private's Avatar
Extreme Talker

Latest Blog Post:
Miss January 2009 . . . Great!
Posts: 199
Name: Tony
Trades: 0
Thanks Tripy for replying. The problem is that I want the ad to be wider, not to have a border.
__________________
Tony Sticks

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
bj_private is offline
Reply With Quote
View Public Profile
 
Old 03-24-2007, 05:09 PM Re: Adsense in javascript file
WebSavvy's Avatar
Extreme Talker

Posts: 166
Name: Deb
Trades: 0
Tony, why don't you try putting the table in your HTML code Vs nesting it inside the JS code?

That might be the problem right there. I've noticed AdSense flipping out and going nuts when it's inside a <div> sometimes too. I have mine inside <dd> (definition description) and it works pretty well.

I'm not sure what DTD you're using, either. Maybe that might have some influence on the problem as well?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
WebSavvy is offline
Reply With Quote
View Public Profile Visit WebSavvy's homepage!
 
Old 03-24-2007, 06:18 PM Re: Adsense in javascript file
bj_private's Avatar
Extreme Talker

Latest Blog Post:
Miss January 2009 . . . Great!
Posts: 199
Name: Tony
Trades: 0
Deb,

Thank you. What I have now is the adsense code in the .js file and the table code placed inside the html file (around the script call). But I want to move the table to the .js file to make updating the ads on my website easier (like changing the colors for instance).

Did you have a look at my 2 pages?
http://www.smartbro.com/index.html
http://www.smartbro.com/index1.html

If I tried to change the adsense back color (from inside the .js file), the table back color will need to be changed as well, so the change will need to be done in the .js file + every .html file that has this type of ad block (all my website pages).

I thought that moving the table code to the .js file will make updates easier, but it seems this ain't working for some reason. Google maybe?

It seems that IE doesn't recognize that the adsense block is placed inside the table (when it's created by the .js file). Any idea why?
__________________
Tony Sticks

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
bj_private is offline
Reply With Quote
View Public Profile
 
Old 03-24-2007, 06:19 PM Re: Adsense in javascript file
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Argh.... Hit the reload on the wrong tab :-(

ok, here I go again.
I've just saved your apge on my comp and tried a bit.

You, my friend, are stuck on an ie nightmare...
It seems that your problem is that IE render first the table, and then only the included js.
Might be because it's an external source, I don't know, the fact is that it works ok on firefox.

No luck trying to use a table in the generated js, but with a div + css, you might get out of this.
Look what I've placed in maintop.js:
Code:
document.writeln('<div style="width:800px;">');
document.writeln('<script type="text/javascript"><!--');
document.writeln('google_ad_client = "pub-2350184081160075";');
document.writeln('google_ad_width = 728;');
document.writeln('google_ad_height = 90;');
document.writeln('google_ad_format = "728x90_as";');
document.writeln('google_ad_type = "text_image";');
document.writeln('google_ad_channel ="7100825086";');
document.writeln('google_color_border = "FFDDDD";');
document.writeln('google_color_bg = "FFDDDD";');
document.writeln('google_color_link = "000000";');
document.writeln('google_color_url = "000000";');
document.writeln('google_color_text = "000000";');
document.writeln('//--></script>');
document.writeln('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
document.writeln('</div>');
Your main table width is 777, so I put 800 pixel width on the container div, this stretching your table to 800.
This looks good in both FF and IE.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 03-24-2007, 06:24 PM Re: Adsense in javascript file
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
If I tried to change the adsense back color (from inside the .js file), the table back color will need to be changed as well, so the change will need to be done in the .js file + every .html file that has this type of ad block (all my website pages).
Code:
document.getElementById("ID_of_table").style.backgroundColor = "#HEX_colour_code";
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-25-2007, 03:44 AM Re: Adsense in javascript file
bj_private's Avatar
Extreme Talker

Latest Blog Post:
Miss January 2009 . . . Great!
Posts: 199
Name: Tony
Trades: 0
Yeahh . . . the problem is fixed.

Tripy, I tried your solution, but it seems that the div has a 0 height which caused it to not appear at all. When I set its height, the problem is back. So the table (or div) actually doesn't show up and the only block that remains visible is the adsense block which is not the same width as my page.

I've tried Chris's solution and it worked just fine.

the .js file has:
Code:
 
/* Begin Google Adsense code */
document.writeln('<script type="text/javascript"><!--');
document.writeln('google_ad_client = "publisher code id";');
document.writeln('google_ad_width = 728;');
document.writeln('google_ad_height = 90;');
document.writeln('google_ad_format = "728x90_as";');
document.writeln('google_ad_type = "text_image";');
document.writeln('google_ad_channel ="7100825086";');
document.writeln('google_color_border = "FFDDDD";');
document.writeln('google_color_bg = "FFDDDD";');
document.writeln('google_color_link = "000000";');
document.writeln('google_color_url = "000000";');
document.writeln('google_color_text = "000000";');
document.writeln('//--></script>');
document.writeln('<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>');
 
document.getElementById("maintopadsense").style.backgroundColor = "#FFDDDD";
/* End Google Adsense code */
and the .html file has:
Code:
 
<TABLE id="maintopadsense" bgcolor="FFDDDD" WIDTH=777 BORDER=1 bordercolor="728FB1" CELLPADDING=0 CELLSPACING=0><tr><td><center>
<!-- Begin Google Adsense code -->
<script TYPE="text/javascript" src="script/maintop1.js"></script>
<!-- End Google Adsense code --> 
<center></td></tr></table>
this way, I can play with everything I need in one place.

Thank you guys, Tripy, Chris and Deb. I really appreciate your help very much.
__________________
Tony Sticks

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
bj_private is offline
Reply With Quote
View Public Profile
 
Old 03-25-2007, 04:02 AM Re: Adsense in javascript file
bj_private's Avatar
Extreme Talker

Latest Blog Post:
Miss January 2009 . . . Great!
Posts: 199
Name: Tony
Trades: 0
Sorry , I forgot BillyRandyFreddieJoeFloydBob. Thank you ;-)
__________________
Tony Sticks

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
bj_private is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Adsense in javascript file

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.44263 seconds with 12 queries