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 :
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>mypage</title>
- <script type="text/javascript" src="../javascripts/jquery-1.7.2.min.js" ></script>
- <script type="text/javascript">
- <!--
- $(document).ready(function(){
- $("body").append($('<div><span>titi</span><div class="mc"><span>toto</span><script>alert("boom!");</script></div></div>').find('.mc'));
- });
- //-->
- </script>
- </head>
- <body>
- </body>
- </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).
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>mypage</title>
- <script type="text/javascript" src="../javascripts/jquery-1.7.2.min.js" ></script>
- <script type="text/javascript" src="../javascripts/jquery.tools.min.js"></script>
- <script type="text/javascript">
- <!--
- $(document).ready(function(){
- $("body").append($('<div><span>titi</span><div class="mc"><span>toto</span><script>alert("boom!");</script></div></div>').find('.mc'));
- });
- //-->
- </script>
- </head>
- <body>
- </body>
- </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 ?