Hello Everyone,

I would like to get some suggestions on a problem I am trying to address.

- I send a request to a 3rd party server (for ads) and a response is received 
from them.
- Currently, I display it inline on the page and things work fine but page 
loading is slow and the 3rd party response can mess up styles, js on my page.
- So, I want to capture this response and dynamically generate iframes and 
write the response into that. This way the other site wont mess up things on my 
site.

Now, the response is not always a simple plain gif, it could be an iframe with 
lots of stuff happening or it could be a URL that further calls some other ad.

So, this is what I did -

- Send a request to the server while the page is loading
- Capture the response by overwriting default document.write() because 
otherwise it would open a new output stream.
adContainer = "";
document.write = function(text){
adContainer += text;
};

- Then dynamically create the iframe -
function generateIframe(iframeId, sDocument) {

var tFrame = document.getElementById(iframeId);
var doc = tFrame.contentDocument;
if (doc == undefined || doc == null)
doc = tFrame.contentWindow.document;
doc.open();
doc.write(sDocument);
doc.close();
}

setTimeout("generateIframe('Left', adContainer)", 500);

Now, this works fine when I am trying to get one ad position.

Add to this a situation when I want to get 5 ad positions.

So, I send only ONE request.

Parse the response for different positions.

Create an iframe each for the positions (so like 5 iframes) and then write the 
responses into them.

I want to know if this is the right way to do it? Sometimes when the responses 
are overly complicated with functions, comments, cookies, blah blah the ad 
doesn't display.

Please let me know your thoughts.

Thanks,
Mandy.

_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to