Loading JavaScript Into Div Dynamically

前端 未结 6 1212
难免孤独
难免孤独 2021-01-22 15:32

I need to load JavaScript code (which I don\'t have control over) from a URL into a div. The JavaScript code is a bunch of document.write() statements. Once the document.write()

6条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-22 16:19

    what you can do is::

    1) initially set the div box to something default (zero or null)

    2) set a timer, for 500/1000 MS and check if the text of the div has changed since last time or not.

    3) if text is still default, goto 2

    4) if text has changed and timeout, take the value as final value, else goto 2.

    considering that the remote JS will do all the writing at once, that is, there is no large gap between its document.writes

提交回复
热议问题