Javascript 元素“脚本”缺少必需的属性“类型”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5138543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Element 'script' is missing required attribute 'type'
提问by RG-3
I am NEW in JS. All I have is a ASP.NET Web Page and I included a JS in my page of showing tweets. Here is the JS code:
我是 JS 新手。我所拥有的只是一个 ASP.NET 网页,并且我在显示推文的页面中包含了一个 JS。这是JS代码:
<div id="tweet">
<font class="title">Recent Tweets</font>
<br />
<script type="text/javascript">
alert($ && $.fn ? $.fn.jquery : "jQuery not defined")
$(function () {
$("#favorites").tweet({
avatar_size: 32,
count: 3,
username: "atpworldtour",
favorites: true,
loading_text: "loading list..."
});
});
</script>
</div>
Now under it is showing me: Microsoft JScript runtime error: '$' is undefined
现在它正在向我展示:Microsoft JScript 运行时错误:'$' 未定义
What am I doing stupid wrong here?
我在这里做错了什么?
Update: Now I am getting this error: Microsoft JScript runtime error: '$' is undefined
更新:现在我收到此错误:Microsoft JScript 运行时错误:'$' 未定义
回答by David Tang
回答by JohnP
Check all your JS includes and make sure that none of them are using type="application/javascript"
. All of them should be using type="text/javascript"
. This is only true if your code fails only in IE.
检查所有 JS 包含并确保它们都没有使用type="application/javascript"
. 他们都应该使用type="text/javascript"
. 仅当您的代码仅在 IE 中失败时,这才是正确的。
I had this issue once and it drove me nuts trying to figure it out
我曾经遇到过这个问题,它让我发疯地想弄清楚
回答by Prakash
In $("#favorites") ,'favorites' is a id of an element on the DOM where probably your tweets will load, do you have element having id 'favorites'?
在 $("#favorites") 中,'favorites' 是 DOM 上一个元素的 id,您的推文可能会在其中加载,您是否有具有 id 'favorites' 的元素?