Questions tagged [document.write]

A DOM Level 2 HTML method that writes a string of text to a document stream opened by document.open().

A DOM Level 2 HTML method that writes a string of text to a document stream opened by document.open().

487 questions
5
votes
5 answers

Why document.write("-->") does not work as expected?

hello

world

nihao

I thought the output of this piece of HTML is hello nihao But it turns out…
JackWM
  • 10,085
  • 22
  • 65
  • 92
5
votes
5 answers

PHP code inside a Javascript's "document.write()"

I need to write some PHP code inside a Javascript's "document.write()". This is a dummy example, but in the future Javascript will generate automatically that PHP code. This is the Hello World I have coded: MyFile.php
user411103
4
votes
1 answer

Aliasing a DOM function (Document.Write) and scripts on other domains

I want to force external 3rd party scripts (on seperate domains) to use my own custom implementation of document.write when I load them on my domain. ie: document.write = function(args) { // My custom Function } This works fine for scripts…
FlySwat
  • 172,459
  • 74
  • 246
  • 311
4
votes
4 answers

How can I create JS event listeners that survive a document.write?

I'm attaching an event listener to the window object. Then later in the script, document.write is being used. (I know, it's evil. I have no choice in the matter.) The problem is, the document.write wipes out my listeners. Is is possible to avoid…
sprugman
  • 19,351
  • 35
  • 110
  • 163
4
votes
5 answers

jQuery & document.write

I have the following script: When I put this into the page, it…
Latox
  • 4,655
  • 15
  • 48
  • 74
4
votes
3 answers

What are all the evils of document.write

I know there are lots of issues with using document.write and I avoid it absolutely. However, I have run into an issue with a 3rd party widget that is using it. I don't quite know how to put into words (and also probably don't know all the…
Endophage
  • 21,038
  • 13
  • 59
  • 90
4
votes
1 answer

Why is there a time lag for document.write of script tag ? And why is the script tag execution delayed?

In my code, I created 5 iframes with script tag in them to get responses from server. we need to do this in parallel. Also because of the cross-domain issues, we did not choose Ajax tech, just creating iframes at the same time to make asynchronous…
Shen Bin
  • 41
  • 2
4
votes
3 answers

Load Advertisement (script) after page using jquery

I'm trying to optimize the page render and download and I'm stuck in this situation... I'd like to load an advertise at the end of page load, I made a simple test PAGE Code:
Marcx
  • 6,806
  • 5
  • 46
  • 69
4
votes
2 answers

Using document.write() and setTimeout() to display time

So, I was reading an article on MSDN here concerning the many ways one can display text to a webpage using JavaScript. However, I found the last example quite confusing as the behavior of the example as described in the article and exhibited in…
user6312047
4
votes
4 answers

Deferrable document.write

alot of web advertising providers use the old document.write method, in my case AdTech. Is it possible to overwrite the document.write method to defer after the onload event?
forberg
  • 63
  • 2
  • 6
4
votes
2 answers

Controlling the scope of a document.write call coming from a third party

I'm writing a webpage that relies on an external javascript file (that I have no control of), which returns data by using document.write's. Is there any way to dynamically call the function without it overwriting the whole document? Here's the most…
Phil
  • 1,110
  • 1
  • 9
  • 25
4
votes
2 answers

How to override JavaScript function from a Firefox extension?

I am trying to intercept calls to document.write for all pages. Setting up the interception inside the page by injecting a script like function overrideDocWrite() { alert("Override called"); document.write = function(w) { return function(s) { …
BruceBerry
  • 1,166
  • 1
  • 9
  • 21
4
votes
3 answers

Load external JavaScript file with document.write into AngularJS app

I got this external JavaScript file(Ad file), which has a document.write() in it. I have tried loading it with $http, and then injecting it into a document.createElement, but the Ad server doesn't support this method; $http.get. I have tried…
Tommy
  • 177
  • 2
  • 10
4
votes
5 answers

Append to a webpage in javascript

What I want to do is that: a webpage with continuously updating content. (In my case is updating every 2s) New content is appended to the old one instead of overwriting. Here is the code I have: var msg_list = new Array( "Hello,…
Lily
  • 5,872
  • 19
  • 56
  • 75
4
votes
4 answers

using the DOM to add elements, document.write

I have just learned (no thanks to IE) that I cannot use document.write scripts in XHTML. However, it seems there is a way around it by using the DOM to add elements. I don't know. It's foreign to me. Here's the JS: copyright=new…
flipflopmedia
  • 517
  • 3
  • 6
  • 16
1 2
3
32 33