Javascript 启用DOM存储时,HTML 5本地存储在ie 11(v 11.0.42)中不工作
我正试图创建一个工作程序,诸如此类。。。本地存储在prod ie 11中无法正常工作。 它在Chrome中运行良好(我希望每个人都能使用它),在我测试它时,它在Aptana的ie内部服务器版本中也能正常工作。Javascript 启用DOM存储时,HTML 5本地存储在ie 11(v 11.0.42)中不工作,javascript,jquery,internet-explorer,internet-explorer-11,Javascript,Jquery,Internet Explorer,Internet Explorer 11,我正试图创建一个工作程序,诸如此类。。。本地存储在prod ie 11中无法正常工作。 它在Chrome中运行良好(我希望每个人都能使用它),在我测试它时,它在Aptana的ie内部服务器版本中也能正常工作。 这是我的密码: jQuery HTML 独角兽 清楚的 这里是入境的 这位好心的先生,正在出境 您的选择将显示在此处 考验我! 找到了答案。 ie不接受localStorage当页面是本地的时,它必须通过服务器位置。 我把页面上传到服务器上,效果很好。 奇怪的是Chrome会让你在本地测
这是我的密码: jQuery HTML
独角兽
清楚的
这里是入境的
这位好心的先生,正在出境
您的选择将显示在此处
考验我!
找到了答案。
ie不接受localStorage当页面是本地的时,它必须通过服务器位置。
我把页面上传到服务器上,效果很好。
奇怪的是Chrome会让你在本地测试。
也解释了为什么它在Aptana中正常工作 我看不出有什么问题。它到底有什么不正确的地方?您在控制台上使用它时是否出现错误?它是否设置为不应该设置的内容,等等。请详细解释,并省略不相关的代码(如css,因为它不会影响本地存储)。@lordrodos。。。很抱歉作为一个问题来表达。。。你能帮我让我的页面在ie中正常工作吗?@PatrickEvans-没有一个与本地存储函数相关的项正确加载。我想最重要的是,使用本地存储测试函数表明本地存储没有设置变量。
function lsTest(){
var test = 'test';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch(e) {
return false;
}
}
$(document).ready(function(){
$("#testbutton").click(function(){
var test = 'test';
if(lsTest() === true){
$("body").css("background", "blue");
$("#test").html(" its here! ");
}else{
$("#test").html(" its BROKE! ");
}
});
});
$(document).ready(function() {
hideElems();
testStorage();
showSSO();
});
function hideElems(){
$(".functionalSelect,#inbound,#outbound").hide();
}
function selection(select){
functionSelect = select;
}
function testStorage(){
var alice = localStorage.getItem('functionthing');
if(!localStorage.getItem('functionthing')) {
populateStorage();
}
else if(localStorage.getItem('functionthing') == "OB"){
$("#outbound").show();
$(".success").html("You have selected Outbound");
$("body").css("background", "grey");
}
else if(localStorage.getItem('functionthing') == "IB"){
$("#inbound").show();
$(".success").html("This means " + alice);
$("body").css("background", "#add8e6");
}
}
function populateStorage(){
var divSet = '<div class="functionalSelect"> <p>Select your function </p>';
var buttons = "<button onClick=selection('OB') class='Out'>Outbound</button> <span> </span><button onClick=selection('IB') class='In'>Inbound</button>";
var end = "</div>";
$(".selector").html(divSet + buttons + end);
}
//==============================================
//Documenation functions
//=============================================
function documentationEntry(){
var Label1 = '<label>SSO: </label><input type="text" id="SSO">';
var Label2 = '<label> Dept: </label><input type="text" value = "frd" id="dept" readonly>';
var select1 = '<span> </span><label>Site: </label><select id = "site"><option value="" disabled selected>Select your option</option>';
var select2 = '<option value="can">Canton</option><option value="chl">Charlotte</option><option value="hyd">Hyderabad</option><option value="ket">Kettering</option><option value="man">Manila</option><option value="phx">Phoenix</option></select>';
var selectButton = '<br /><br /><button id="sendInfo">Lock Info</button>';
select1 += select2;
$(".entryHeader").html(Label1 + Label2 + select1 + selectButton);
}
function showSSO(){
var caterpiller = localStorage.getItem('SingleSignOn');
var marchhare = localStorage.getItem('department');
var queenofHearts = localStorage.getItem('entered_site');
if(!localStorage.getItem('SingleSignOn')) {
documentationEntry();
}else{
$('.entryHeader').hide();
$(".report").html(marchhare + "/" + queenofHearts + "/ ib/ stuff" + caterpiller);
}
}
$(document).ready(function(){
$("#sendInfo").click(function(){
var SSO_Entry = $('#SSO').val();
var entered_site = $('#site :selected').val();
var dept = 'frd';
if(!SSO_Entry || site == ""){
$(".report").html("Your Entry is incomplete");
$(".report").css("color", "red");
}else{
localStorage.setItem('department', dept);
localStorage.setItem('entered_site', entered_site);
localStorage.setItem('SingleSignOn', SSO_Entry);
showSSO();
$(".entryHeader").hide();
$(".report").html("");
}
});
});
//===========================================
//End documentaion functions
//===========================================
$(document).ready(function(){
$(".functionalSelect").click(function(){
if(functionSelect == "OB"){
localStorage.setItem('functionthing', functionSelect);
$(".success").html("your selection is Outbound");
$("body").css("background", "grey");
}else if(functionSelect == "IB"){
localStorage.setItem('functionthing', functionSelect);
$(".success").html("your selection is Inbound");
$("body").css("background", "#add8e6");
}
$(".selector").hide();
});
});
$(document).ready(function(){
$(".clearit").click(function(){
localStorage.clear();
location.reload();
});
});
#entryWrapper{
width:600px;
padding:5px;
border:solid 1px black;
}
.clearit{
float:right;
}
.success{
height:50px;
}
.entryHeader{
width:475px;
height:75px;
border:solid 1px black;
padding: 5px;
}
.entryHeader input{
width:100px;
}
<!DOCTYPE html>
<html>
<head>
<title>Unicorn</title><meta http-equiv="X-UA-Compatible" content="IE=edge"
charset="UTF-8"/>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
</script>
<script>
</script>
<style>
</style>
</head>
<body>
<section id="entryWrapper">
<button class="clearit">clear</button>
<section class="entryHeader"></section>
<section class="report"></section>
<section class = "selector"></section>
<div id="inbound"> this right here is inbound</div>
<div id="outbound">and this, kind sir, is outbound</div>
<div class ="success"><p>Your selection will be shown here</p></div>
</section>
<div id="test"></div>
<button id="testbutton">test me!</button>
</body>
</html>