简体   繁体   English

如何链接回index.html上的选项卡?

[英]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.

相关问题 如何将contact.handlebars添加为index.html而不是contact.html的链接? - How do I add contact.handlebars as a link to my index.html instead of contact.html? 如何将通过 function 按钮输入的内容放回 index.html? - how do i put what is inputted with buttons through a function back to an index.html? 如何将 js 文件链接到 Node.js web 服务器中的 index.html? - How do I link a js file to index.html in a Node.js web server? 如何从Workbox实际显示更新的index.html? - How do I actually display my updated index.html from Workbox? 如何在 index.html 文件中定义变量? (window.parentPage = true;) - How do I define a variable in my index.html file? (window.parentPage = true;) 如何使用 JavaScript 在我的 index.html 文件中嵌入 API 调用? - How do I embed an API call in my index.html file using JavaScript? 如何将外部.js文件添加到index.html? (VueJS2) - How do I add an external .js file to my index.html? (VueJS2) 如何将我的index.html与Systemsj配置为使用现有的包? - How do I configure my index.html with Systemsj to use an existing bundle? Angular 2 - 如何使关键字和描述的index.html文件标题和元标记动态化 - Angular 2 - how do I make my index.html files title and meta tags for keywords and description dynamic 如何在电子上加载 index.html 文件? - How do I load the index.html file on electron?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM