Javascript sessionStorage.setItem在firefox中不工作/无法将div的id从第1页传递到第2页
下面的代码适用于Chrome,但不适用于Firefox。我想打开相应的手风琴面板上的“关于”页时,它的链接是在“主页”点击。[onclick-主页必须关闭,关于页面必须打开] 主页:Javascript sessionStorage.setItem在firefox中不工作/无法将div的id从第1页传递到第2页,javascript,html,firefox,Javascript,Html,Firefox,下面的代码适用于Chrome,但不适用于Firefox。我想打开相应的手风琴面板上的“关于”页时,它的链接是在“主页”点击。[onclick-主页必须关闭,关于页面必须打开] 主页: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootst
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<style type="text/css">
.bs-example{
margin: 20px;
}
a{
margin:20px;
}
</style>
<script type='text/javascript'>//<![CDATA[
function myFunctionId (id) {
sessionStorage.setItem("sent", id);
window.open("about.html","_self");
}
//]]>
</script>
</head>
<body style="padding-top:50px;">
<a onclick="myFunctionId(this.id);" id="header1">Panel1</a></br>
<a onclick="myFunctionId(this.id);" id="header2">Panel2</a></br>
<a onclick="myFunctionId(this.id);" id="header3">Panel3</a></br>
</body>
</html>
.bs示例{
利润率:20px;
}
a{
利润率:20px;
}
//
HTML代表超文本标记语言。HTML是描述网页结构的主要标记语言
Bootstrap是一个功能强大的前端框架,用于更快、更简单的web开发。它是CSS和HTML约定的集合
CSS代表级联样式表。CSS允许您为给定的HTML元素指定各种样式属性,例如颜色、背景、字体等
发现问题..必须使用localStorage.setItem/localStorage.getItem,而不是使用sessionStorage.setItem/localStorage.setItem
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of Bootstrap 3 Accordion</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<style type="text/css">
.bs-example{
margin: 20px;
}
</style>
<script type='text/javascript'>//<![CDATA[
$(document).ready(function(){
var a = sessionStorage.getItem("sent");
if (a == "header1") {
document.getElementById('collapseOne').classList.add('in');
} else if (a == "header2") {
document.getElementById('collapseTwo').classList.add('in');
} else if (a == "header3") {
document.getElementById('collapseThree').classList.add('in');
}
else {
greeting = "Good evening";
}
document.getElementById("demo").innerHTML = greeting;
});
//]]>
</script>
</head>
<body><p id="demo"></p>
<div class="bs-example">
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">1. What is HTML?</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse">
<div class="panel-body">
<p>HTML stands for HyperText Markup Language. HTML is the main markup language for describing the structure of Web pages. <a href="http://www.tutorialrepublic.com/html-tutorial/" target="_blank">Learn more.</a></p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">2. What is Bootstrap?</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
<p>Bootstrap is a powerful front-end framework for faster and easier web development. It is a collection of CSS and HTML conventions. <a href="http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/" target="_blank">Learn more.</a></p>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseThree">3. What is CSS?</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse header3">
<div class="panel-body">
<p>CSS stands for Cascading Style Sheet. CSS allows you to specify various style properties for a given HTML element such as colors, backgrounds, fonts etc. <a href="http://www.tutorialrepublic.com/css-tutorial/" target="_blank">Learn more.</a></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>