dourong4031 2014-05-24 11:17
浏览 43

创建指向刷新页面的ID的链接

I am working on a project that uses javascript to make tabs. It has 3 tabs.

Tab three has an id of tab3, what I need is a refresh button that will be on tab3 that will refresh the page. Problem I'm having is if you click on tab3 it will display tab3 data, but it does not change the url. So the refresh button isn't working.

I tried an onclick javascript that reloads the page using location.reload() which reloads the page but not to the tab3. So I put that on a link,

<a href="<?php echo $_SERVER['REQUEST_URI']; ?>#tab3" onclick="reloadPage();" >Refresh</a> 

This will link to the correct location, the URL then has #tab3 at the end, then the Javascript runs and it reloads back to the url without the #tab3.

So I then tried this that I saw somewhere.

<a href="javascript:;" onclick="window.location = '<?php echo $_SERVER['REQUEST_URI']; ?>#tab3;'">Go</a>

Which links, but doesn't reload.

What is the best way to do this?

  • 写回答

3条回答 默认 最新

  • douhuai4155 2014-05-24 11:22
    关注

    Try this-

    <a href="#tab3" onclick="location.reload();" >Refresh</a> 
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题