我在将havascript添加到我的HTML代码时遇到了麻烦。该代码适用于JSfiddle,但不适用于我的html代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>
<link href="dropdownmenu.css" rel="stylesheet" type="text/css" />
<body>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '593528484105939',
xfbml : true,
version : 'v2.2'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if(d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "http://connect.facebook.net/en_US/sdk.se";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
所以这是javascript代码之一,即使我将开始标记更改为,它也不起作用
<script type="text/javascript">
答案 0 :(得分:0)
关闭Head
标记,然后重试,如果仍无效,则尝试使用
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
您可以通过替换
来使用上述两个或其中一个链接<script type='text/javascript' src='http://code.jquery.com/jquery-1.9.1.js'></script>
答案 1 :(得分:-1)
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<link href="dropdownmenu.css" rel="stylesheet" type="text/css" />
</head>
<body>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '593528484105939',
xfbml : true,
version : 'v2.2'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if(d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "http://connect.facebook.net/en_US/sdk.se";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
</body>