我正在尝试创建一些javascript代码,这些代码会在我的网站上的某些日子显示一个javascript表单(来自formstack.com)。但是我似乎无法让它发挥作用。我认为第一部分是正确的,但当它有javascript代码显示其他JavaScript时我很困惑。请帮忙!!!感谢
<head>
<script type="text/javascript">
var theDate = new Date();
var dayOfWeek = theDate.getUTCDay();
// Returns true if the restaurant is open
function isOpen()
{
//I'll fill this in later, for now, return true
return true;
}
</script>
</head><body>
<script type = "text/javascript">
if(isOpen())
{
<script type="text/javascript" src="http://www.formstack.com/forms/js.php?1134414-uqmj2UXxEw-v2"></script><noscript>
<a href="http://www.formstack.com/forms/CampusEnterprises-chopped_greens_order_form__copy" title="Online Form">
Online Form - Chopped Greens Order Form- COPY</a>
}
</script>
</body>
答案 0 :(得分:3)
您正试图在JavaScript中显示原始HTML,但这不起作用。
<script type="text/javascript">
if(isOpen())
{
document.write( '<script type="text/javascript" src="http://www.formstack.com/forms/js.php?1134414-uqmj2UXxEw-v2"></script>' );
}
</script>
尽管如此,更好的方法是使用服务器端语言代替JavaScript来实现这样的目标。