[英]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('JavaScript text');";外部 javascript 文件:var someVariable="document.write('JavaScript text');";
and output should be: JavaScript text和 output 应该是: JavaScript 文本
You can't do that with document.write().
你不能用
document.write().
write()
only gets executed once. write()
只执行一次。 For other javascript functions you use eval()
but again it won't work for write()
对于其他 javascript 函数,您使用
eval()
但它再次不适用于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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.