开发者

How can run a script tag in html page which is already generated by an external javascript file

extenal javascript file: var someVariable="document.write('Java开发者_运维问答Script text');";

and output should be: JavaScript text


You can't do that with document.write(). write() only gets executed once. For other javascript functions you use eval() but again it won't work for write()

code is:

<html>
<head>
    <title>JavaScript</title>
        <script type="text/javascript">
            var somevariable="<script>document.write('This is a javascript variable');</script>";
        </script>
    </head>
<body>
    <script type="text/javascript">
        document.write(somevariable);
    </script>
</body>
</html>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜