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>
精彩评论