Thanks Kevin, is there any work around if I don't have control of the content?
One other question related to this is if the returned javascript tries to invoke an http request using XMLHttpRequest#send, you would get: Uncaught script error: Uncaught NetworkError: Failed to execute 'send' on 'XMLHttpRequest'. Is this intended behavior to prevent unwanted ajax requests? On Thursday, March 17, 2016 at 3:44:49 AM UTC+11, Kevin Reid wrote: > > On Tue, Mar 15, 2016 at 9:38 PM, Nova Tan <[email protected] <javascript:> > > wrote: > >> Thanks for the response, sorry I only saw it today. I tried the snippet >> you posted as well but couldn't get it to work. Basically I used the >> snippet below: >> caja.load(document.getElementById('some-iframe').contentWindow.document, >> uriPolicy, function(frame) { >> frame.code('http://localhost:8080/bla.js', >> 'application/javascript').run(); >> }); >> >> With the same javascript response: >> document.writeln("<SCRIPT language='JavaScript1.1' SRC=\" >> https://ad.doubleclick.net/some-ad\">"); >> document.writeln("</SCRIPT>"); >> >> I get this error: Uncaught script error: Uncaught Error: shouldn't >> happen: start tag <script...> while in text insertion mode for SCRIPT in >> source: "http://localhost:8080/bla.js" >> > > I haven't reminded myself of the exact details, but Caja has limitations > in its support for document.write and I think you are hitting one of them > by putting the <script> and </script> in separate calls. > > If the guest content is under your control, I recommend not using > document.write — it is generally considered to be unwise in modern web > development due to its performance impact and semantic gotchas, and all of > its uses can be replaced with DOM node manipulation. > -- --- You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
