跟踪刷新页面时查看哪个选项卡 [英] Keep track of which tab was being viewed when page is refreshed

查看:133
本文介绍了跟踪刷新页面时查看哪个选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含三个标签的网页,根据点击哪个标签,可以看到相应的内容。
这显示/隐藏的内容点击标签是由Javascript处理。

I have a webpage which has three tabs, and depending on which tab is clicked, the appropriate content is visible. This showing/hiding of the content on clicking of tabs is handled by Javascript.

我的问题是,如果我正在查看第三个选项卡,然后刷新页面中,页面不会刷新到第三个选项卡的内容可见,而是返回到第一个选项卡的内容。

My issue is, if I am viewing the third tab and then refresh the page, the page does not refresh to the third tab's contents being visible but instead, back to the first tab's contents.

有没有什么办法,当执行javascript时,我给URL添加一个GET参数,所以在页面加载时我的PHP脚本可以检查GET参数并显示正确的内容吗?

Is there any way, when the javascript executes, for me to add a GET parameter to the URL, so on page load my PHP script can check for the GET parameter and display the correct content?

解决方案

当点击标签时,将URL添加到URL作为锚点,例如 http://www.mysite.com/page.html#tabId

Addtab id to the URL as an anchor when tab is clicked, e.g. http://www.mysite.com/page.html#tabId

然后,当页面加载时,您检查URL中是否存在标签ID并激活所需的标签

Then when page loads you check for presence of tab id in url and activate required tab

这篇关于跟踪刷新页面时查看哪个选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆