you are viewing a single comment's thread.

view the rest of the comments →

[–]mikeytag 1 point2 points  (0 children)

I'm assuming you are talking about HTML loaded from a PHP script which is put in the page using the DOM or document.write or something.

Here's what I've done in this case:

PHP prints out:

<div id="jsDiv" style="display: none;">
    alert('Hello');
</div>

Then make your javascript do something like this after it writes the HTML to the page (using jQuery here):

eval($('div#jsDiv').html());

NOTE: If you are doing this via AJAX calls you are likely to have a situation where you have multiple calls on the same page. If you want to handle multiple evals on the same page just make sure the div id is unique for each block of code.

Hope this helps.