On Thursday 29 June 2006 02:35, Maninder, Singh wrote: > - 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.
> - 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){
^^^^^^^^^^^^^^ ack!
why not just generate the iframe dynamically, then append it to your page when
you're ready? Have a div or something already in place (and styled
appropriately) and use appendChild to add it.
I guess basically what I"m saying is something like this (requires builder.js
from scriptaculous, but is fairly trivial with normal DOM functions, I'm just
lazy):
var iframe = Builder.node('iframe', {'class':'advertisement',
'src':'someurl'});
Event.observe(iframe, 'load', function(ev) {
$('leftadframe').appendChild(this);
}.bindAsEventListener(iframe));
much prettier, and without any nasty document.write garbage :)
note that here I'm assuming an iframe has an onload event, and that it fires
when the content has been loaded into it :) I'm not really sure, but that
should give you some ideas.
document.write should die a slow, horrible, painful death. Please avoid using
it at all costs.
--
Jeremy Kitchen ++ [EMAIL PROTECTED]
http://www.pirate-party.us/ -- defend your rights
pgpq4Za5sgOfK.pgp
Description: PGP signature
_______________________________________________ Rails-spinoffs mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
