jQuery和不同的浏览器
我在localhost上的页面需要jQuery和jQuery ui,它可以在localhost中的chrome、Firefox和InternetExplorer11上工作,但当我将文件上载到服务器时,jQuery ui就不再在InternetExplorer11上工作。这个问题显然已经解决了,但我不明白答案,有人能解释一下吗 我的代码:jQuery和不同的浏览器,jquery,html,Jquery,Html,我在localhost上的页面需要jQuery和jQuery ui,它可以在localhost中的chrome、Firefox和InternetExplorer11上工作,但当我将文件上载到服务器时,jQuery ui就不再在InternetExplorer11上工作。这个问题显然已经解决了,但我不明白答案,有人能解释一下吗 我的代码: <!doctype html> <html lang="en"> <head> <meta http-equiv="
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="edge">
<!--Here is the css file you are using for your project UI included from CDN (content delivery network)-->
<link rel="stylesheet" href="js/jquery-ui.css" />
<!--Here is the main jQuery file included from CDN.You can you any other source-->
<script src="js/jquery-1.9.1.js"></script>
<!--Here is jQuery UI added from CDN-->
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<!-- Custom styles for the interface goes here -->
<style>
#draggable {
background: none repeat scroll 0 0 #33CCFF;
color: #FFFFFF;
font-family: verdana;
height: 150px;
padding: 0.5em;
text-align: center;
width: 150px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
</style>
<!-- Draggable script goes here -->
<script>
$(function() {
alert();
//Select the element of the page you want to make draggable and add the function
//.draggable() after that
$( "#draggable" ).draggable();
});
</script>
</head>
<body>
<!-- In that case this div with id of #draggable draggable here
and any conmonent inside that draggable div will be also draggable with that -->
<div id="draggable" class="ui-widget-content">
<p>Drag me around</p>
</div>
</body>
</html>
#可拖动的{
背景:无重复滚动0 0#33CCFF;
颜色:#FFFFFF;
字体系列:verdana;
高度:150像素;
填充:0.5em;
文本对齐:居中;
宽度:150px;
-webkit边界半径:3px;
-moz边界半径:3px;
边界半径:3px;
}
$(函数(){
警惕();
//选择要使其可拖动的页面元素并添加函数
//.draggable()之后
$(“#可拖动”).draggable();
});
把我拖来拖去
至于另一个问题的答案,问题可能是由愚蠢的IE进入兼容模式引起的。您需要将这一行放在
标记后面:
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
这个
X-UA-Compatible
meta标签告诉IE尽可能使用最新版本,不要进入兼容模式(例如模拟IE7)。“我不确定他们是怎么做到的”做了什么?那么,这个问题的答案不起作用了?@digitalfresh:我想这是个神奇的东西。:)尝试将
添加到您的页面。您能否提供一个指向服务器的链接,将代码放在服务器上进行测试?我认为问题出在您的主机上。它会自动尝试在代码底部添加一些javascript(在结束标记之后)。可能此javascript会阻止IE。请尝试其他托管提供商。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<!-- Your title, meta, link and script tags goes here -->
</head>
<body>
<!-- Your Body tags goes here -->
</body>
</html>