[英]How do I link back to a tab on my index.html?
I have three tabs with projects on https://gallant-euclid-b426b2.netlify.com 我在https://gallant-euclid-b426b2.netlify.com上的项目有三个标签
When you click on a project, you are directed to a new page. 当您单击一个项目时,您将被定向到一个新页面。 I want the tabs to work on that new page. 我希望这些标签可以在该新页面上使用。 How do I make this happen? 我如何做到这一点? So the tab 'school' would link back to the school tab on index.html and the 'projects' tab to the projects tab. 因此,“学校”标签将链接回index.html上的“学校”标签,并将“项目”标签链接到“项目”标签。
(The back to school tab actually already works, because that's the default tab) (返回学校标签实际上已经可以使用,因为这是默认标签)
I don't want to use history.back()
because someone might send a project link to someone and then there might not be a previous page etc. 我不想使用history.back()
因为某人可能将项目链接发送给某人,然后可能没有上一页等。
<div class="bar">
<div class="tab">
<button class="tablinks" id="defaultopenTab" onclick="openTab(event, 'school')">school</button>
<button class="tablinks" onclick="openTab(event, 'projects')">projects</button>
<button class="tablinks" onclick="openTab(event, 'about')">about</button>
</div>
</div>
I hope there is a solution where I can simply say something like: 我希望有一个解决方案,在这里我可以简单地说:
onclick="location.href='index.html'; openTab(event, projects)"
The tab code on page office.html needs to be the same as in index.html office.html页上的标签代码必须与index.html中的标签代码相同
<div id="school" class="tabcontent">
<h1>industrial design</h1>
<div class="project" onclick="location.href='office.html';">
<div class="img" id="some"></div>
<div class="name">Project 1</div>
<div class="label">Industrial Design</div>
</div>
<div class="project" onclick="location.href='office.html';">
<div class="img" id="some"></div>
<div class="name">Project 2</div>
<div class="label">Industrial Design</div>
</div>
<div class="project_long" onclick="location.href='office.html';">
<div class="img_long" id="stage"></div>
<div class="name">Stage</div>
<div class="label">Industrial Design</div>
</div>
<div class="project" onclick="location.href='office.html';">
<div class="img" id="office"></div>
<div class="name">Office Rating System</div>
<div class="label">Industrial Design</div>
</div>
</div>
You can do this statically by copying and pasting or through a script. 您可以通过复制和粘贴或通过脚本来静态地执行此操作。 For instance, you could bind each tab to a shared javascript file. 例如,您可以将每个选项卡绑定到共享的javascript文件。
Change 更改
<div class="project" onclick="location.href='office.html';">
to 至
<div class="project" id="office">
then in the script 然后在脚本中
$(document).on("click","#office",function(){
windows.open("office.html","_self");
});
Do that for each tab. 对每个选项卡执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.