-1

Page a.com loads a javascript file from b.com like this:

<script src="http://b.com/file.js"></script>

b.com/file.js adds some content to a.com.

The file.js is like this:

document.write("<script ... <link rel=\"stylesheet\" ... <div> ... <form> ...");

But I know document.write is not good. But what are the alternatives? I don't think it's "ok" to add complete html code inside document.write ... or not?

yoshi
  • 1,287
  • 3
  • 15
  • 28

1 Answers1

1

There is nothing "not good" about using document.write here, especially when you want to add in some <script> to the page. If you are just using it to add DOM elements, you can consider using some DOM manipulation methods.

Archy Will He 何魏奇
  • 9,589
  • 4
  • 34
  • 50