![](/img/trans.png)
[英]How do I add contact.handlebars as a link to my index.html instead of contact.html?
[英]How do I link back to a tab on my index.html?
我在https://gallant-euclid-b426b2.netlify.com上的项目有三个标签
当您单击一个项目时,您将被定向到一个新页面。 我希望这些标签可以在该新页面上使用。 我如何做到这一点? 因此,“学校”标签将链接回index.html上的“学校”标签,并将“项目”标签链接到“项目”标签。
(返回学校标签实际上已经可以使用,因为这是默认标签)
我不想使用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>
我希望有一个解决方案,在这里我可以简单地说:
onclick="location.href='index.html'; openTab(event, projects)"
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>
您可以通过复制和粘贴或通过脚本来静态地执行此操作。 例如,您可以将每个选项卡绑定到共享的javascript文件。
更改
<div class="project" onclick="location.href='office.html';">
至
<div class="project" id="office">
然后在脚本中
$(document).on("click","#office",function(){
windows.open("office.html","_self");
});
对每个选项卡执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.