iamnoah / writeCapture

Utility to assist the Ajax loading of HTML containing script tags that use document.write. Mailing List: http://groups.google.com/group/writecapturejs-users
http://iamnoah.github.com/writeCapture
Other
241 stars 38 forks source link

Problem with Firefox. #11

Closed bbaruela closed 13 years ago

bbaruela commented 14 years ago

The following codes work on all major browsers except on Firefox.

$.writeCapture.proxyGetElementById = false; $.writeCapture.writeOnGetElementById = true;

$("#spotAd1").writeCapture( "html", "<script type=\"text/javascript\" src=\"http://partner.googleadservices.com/gampad/google_service.js\">\n" + "<script type=\"text/javascript\">\n" + "GS_googleAddAdSenseService(\"ca-pub-5073653240216796\");\n" + "GS_googleEnableAllServices();\n" + "<script type=\"text/javascript\">\n" + "GA_googleAddSlot(\"ca-pub-5073653240216796\", \"FullBanner_Custom_Bot_HomePage\");\n" + "<script type=\"text/javascript\">\n" + "GA_googleFetchAds();\n" + "\n" + "\n" + "<script type=\"text/javascript\">\n" + "GA_googleFillSlot(\"FullBanner_Custom_Bot_HomePage\");\n" + "\n" + "\n" );

It must display an ad but when I load it using Firefox, two errors came up:

  1. uncaught exception: [Exception... "Illegal operation on WrappedNative prototype object" nsresult: "0x8057000c (NS_ERROR_XPC_BAD_OP_ON_WN_PROTO)" location: "JS frame :: http://partner.googleadservices.com/gampad/google_ads.js :: anonymous :: line 74" data: no] [Break on this error](no source for)
  2. window.document_write_ajax_callbacks is undefined

Can you please help me to figure out what wrong in here?

I'm using the jquery.writeCapture-1.0.5-min.js file.

iamnoah commented 14 years ago

Hmmm, so I don't think we can really say that it works in all other browsers. In Safari, FF and Chrome at least, 2 document.write calls are getting through, so I'd be surprised if the ads actually work like this.

Out of curiosity, what are you trying to do here? Why are you loading Google ads this way?

bbaruela commented 14 years ago

We do this way because we have a tag manager where we can choose which ads or tags are going to be loaded to the browser.

iamnoah commented 14 years ago

Do you have a public URL where I can view the ads as they're supposed to work and one replicating the problem? I don't see the same errors as you.

bbaruela commented 14 years ago

Yes. You may try this: http://qatracking.clanteam.com/test_pages/browser/ads/tn_browser_ads_dc_publisher.php

Open that link to a Firefox with firebug installed for you to see the error message. And if you want to see what it will display when it has no error, open it to another browser such as chrome.

iamnoah commented 14 years ago

I'm not getting the same results as you.

So in Chrome, I see the table but nothing happens. In Firefox, I see the table and an adsense add underneath. In Safari, the page is overwritten by the ad. There is too much going on here, can you simplify the page down to a minimal HTML file with only the bare minimum JS needed?

Also, what version of Firefox is this in?

bbaruela commented 14 years ago

I made this html page that contains online the writeCapture call and includes the jquery and writeCapture js file.

Here is the link: http://animalianz.com/tntest.html

I'm using Firefox 3.6.8 with firebug installed. And to see the ad display, I'm using Chrome 4.0.249.43.

Hope this help you.

I really need help.I'm stock to this. Thank You.

iamnoah commented 14 years ago

It's actually not working in Chrome either. The ad is overwritting the whole page. You see the ad, but all other content is wiped out. It looks like the latest Firefox has a problem with the script, which is why you see an error, but it's not working in any case.

Unfortunately, the adsense code is heavily obfuscated, so debugging this isn't really feasible. writeCapture can't be 100% compatible with everything out there, and it's possible that the Adsense code is specifically designed to prevent dynamic loading like this.

I've added a section to the README entitled "What to try when writeCapture fails". I think the iframe approach might work for what you're trying to do. If you do find a way to make writeCapture work, please let me know.