简体   繁体   English

我的Javascript代码有什么问题?

[英]What's wrong with my Javascript code?

I'm trying to create some javascript code that will display a javascript form (from formstack.com) on my website certain days of the week. 我正在尝试创建一些JavaScript代码,这些代码将在一周的某些天在我的网站上显示一个javascript表单(来自formstack.com)。 However I can't seem to get it working. 但是我似乎无法正常工作。 I think the first portion is correct, but when it gets to having javascript code to display other javascript I'm confused. 我认为第一部分是正确的,但是当涉及到用JavaScript代码显示其他JavaScript时,我感到困惑。 Please help!!! 请帮忙!!! Thanks 谢谢

<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>

You're trying to display raw HTML inside JavaScript which won't work. 您正在尝试在JavaScript中显示原始HTML,该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>

That said, even better would be to use a server-side language instead of JavaScript for things like this. 也就是说,更好的方法是使用服务器端语言而不是JavaScript。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM