Brawia
Brawia

Reputation: 33

Change innerHTML of a php DOMElement

In fact during a JS script I change the innerHTML attribute of a DIV, and this content itself contains JS code.

The problem: This code is not executed js on the page.

Upvotes: 0

Views: 76

Answers (1)

Ivan Nikolchov
Ivan Nikolchov

Reputation: 1574

If you want to execute some javascript after the page loads, you need to insert it in the head of the document:

var script = document.creatElement('script');
script.src = "path to some script";
script.type = "text/javascript";
document.getElementsByTagName('head')[0].appendChild(script);

or to use eval()

Upvotes: 1

Related Questions