在另一页上打开扰流板
Open spoiler on a separate page
本文关键字:一页 更新时间:2023-09-26
在我的网站上,我必须构建多个剧透。我计划用这个代码来创建扰流板:如何创建多个扰流板按钮。
我正在寻找一种简单的方法来在页面上创建一个链接,该链接指向页面并打开页面上的扰流板
换言之,我需要a.html页面上的目录,以查看B.html页面上的剧透。
但是,如果您直接进入页面B.html,则默认情况下应关闭所有剧透,并可通过单击剧透标题来打开和关闭它们。
任何现成的解决方案都将不胜感激。解决方案不一定要基于我上面提供的代码。
好吧,我知道这是完全错误的,但这就是我所尝试的。
A.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
.spoiler {
display:none;
width:100%;
height:50px;
background-color:red;
margin-bottom:10px;
}
.contentBoxFooter{position:absolute;bottom:10px;}
</style>
</head>
<body>
<div id="x" class="spoiler">Content1</div>
<div id="y" class="spoiler">Content2</div>
<div id="z" class="spoiler">Content3</div>
<div class="contentBoxFooter">
<a href="B.html#x" class = "spoilerButton">Show/Hide</a>
<a href="B.html#y" class = "spoilerButton">Show/Hide</a>
<a href="B.html#z" class = "spoilerButton">Show/Hide</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</body>
</html>
B.html
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
.spoiler {
display:none;
width:100%;
height:50px;
background-color:red;
margin-bottom:10px;
}
.contentBoxFooter{position:absolute;bottom:10px;}
</style>
</head>
<body>
<div id="x" class="spoiler">Content1</div>
<div id="y" class="spoiler">Content2</div>
<div id="z" class="spoiler">Content3</div>
<div class="contentBoxFooter">
<a href="#x" class = "spoilerButton">Show/Hide</a>
<a href="#y" class = "spoilerButton">Show/Hide</a>
<a href="#z" class = "spoilerButton">Show/Hide</a>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".spoilerButton").click(function (e) {
e.preventDefault()
var foo=$(this).attr('href')
$(''+foo).slideToggle(1000);
});
});
</script>
</body>
更新:以下是我需要的示例:https://support.google.com/plus/#topic=3049663每个部分都会在链接末尾添加一个唯一的URL。
如果您不想在查询url时执行此操作,则需要在新的javascript window
中打开B.html
。
在那里你可以做一些事情,例如:
window win = window.open("B.html");
win.document.myVariable = "test";
然后你可以像通常使用myVariable
一样在网站B.html上读取变量
编辑:如果你只想将页面B.html
加载到页面A.html
中的扰流板中,那么它只是一个jquery命令:
$("#spoiler").load("B.html");
我在这里找到了一个解决方案:https://forum.jquery.com/topic/accordion-open-a-specific-tab-with-link-from-another-page
但我最终选择了手风琴,而不是我最初想要的一套剧透。
相关文章:
- 如何获取不属于我项目的上一页的URL
- 如何在Facebook上的iframe应用程序中使后退按钮返回到上一页
- 使用Booklet Jquery插件,我如何验证最后一页是否显示
- 如何在一页网站中使用PHP重定向到一个页面
- Javascript并不是显示在每一页上
- 如何在一页上显示多个Highcharts图表
- jQuery分页下一页和上一页按钮在点击零或超过最后一页后失败
- 如何为AngularJS制作智能表中第一页和最后一页的跳过按钮
- Bootstrap一页导航Fluid网站最小化问题
- 返回上一页时,Javascript仍处于活动状态
- 将jsp重定向到servlet,然后重定向到下一页
- 如何在重定向到asp.net中单击按钮的下一页之前应用javascript警报
- 传递表单值并移动到另一页
- 如何获取数组详细信息另一页
- 警报中的window.location必须重定向到上一页
- 一页签出在Magento版本1.7.0.2中不起作用
- 获取/保留上一页's具有SmoothState的URL
- 简单的一页水平滚动
- 翻开一页'的javascript变量更改为提要
- 记住下一页的段塞