Append html with executed code in the embedded script tag

Append html with executed code in the embedded script tag


Hello,

jquery tools forum in now unaccessible so I post my discussion here for now.

I'd like that the code in script tag of the HTML appended in body (line number 13), to be executed

Here is the code :
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>mypage</title>

  6. <script type="text/javascript" src="../javascripts/jquery-1.7.2.min.js" ></script>

  7. <script type="text/javascript">
  8. <!--
  9. $(document).ready(function(){
  10. $("body").append($('<div><span>titi</span><div class="mc"><span>toto</span><script>alert("boom!");</script></div></div>').find('.mc'));
  11. });
  12. //-->
  13. </script>
  14. </head>
  15. <body>

  16. </body>
  17. </html>

The alert function is executed and  you'll see the alert popup in your browser when displaying this page.

(You can also put the code in blue it in a javascript console on this page  http://jquery.com/   for example, you'll see the alert popup).


But when integrating  (line number 8 jquery tools library 1.2.7 (downloaded without jquery here :  http://jquerytools.org/download/ )

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>mypage</title>

  6. <script type="text/javascript" src="../javascripts/jquery-1.7.2.min.js" ></script>
  7. <script type="text/javascript" src="../javascripts/jquery.tools.min.js"></script>

  8. <script type="text/javascript">
  9. <!--
  10. $(document).ready(function(){
  11. $("body").append($('<div><span>titi</span><div class="mc"><span>toto</span><script>alert("boom!");</script></div></div>').find('.mc'));
  12. });
  13. //-->
  14. </script>
  15. </head>
  16. <body>

  17. </body>
  18. </html>

        The code in script tag appended to body is not executed anymore.

        (You can also put the code in blue it in a javascript console on this page  http://jquerytools.org/   for example, you won't see the alert popup).

        Do you know the reason why ? Is it a bug in jquery tools ?