I am trying to load an external JavaScript file dynamically into an HTML element to preview the ad tag. The script is loaded and executed, but the script contains "document.write", which has a problem that executes correctly, but no errors.
<html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script type="text/javascript"> $(function() { source = 'http://ib.adnxs.com/ttj?id=555281'; </script> </head> <body> </body> </html>
I can make it work if
- If I transfer the source to the same domain for testing
- If the script has been modified to use document.createElement and appendChild instead of document.write, like the code above.
I have no way to modify the script since it is being created and hosted by a third party.
Does anyone know why document.write will not work correctly? And is there a way around this?
Thanks for the help!
javascript
jadent
source share