用不同的锚点重新加载页面 [英] Reload page with different anchor

查看:142
本文介绍了用不同的锚点重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是陷入了一个问题。我有一个Jquery UI选项卡的页面。每个标签都可以通过向链接添加一个哈希标签从不同的页面访问,并使用我需要的标签加载页面。不过,我也需要访问同一页面内的不同标签。我想到的是将 target =_ parent添加到带有哈希标记的链接:

 < a href =pictures.htm#tab2target =_ parent> 

它只是在IE中需要的。它使用不同的哈希标签重新加载页面,但由于某些原因,Chrome和Firefox每次都加载相同的选项卡。我需要的是为链接创建一个 javascript函数,它将用不同的哈希标记完全重新加载页面。



我想出了这个代码:

 函数gototab(重新加载)
{
window.location.href ='pictures.htm #TAB2' ;
window.location.reload(true);
}

< a href =pictures.htm#tab2onclick =gototab();>打开标签2< / a>

我觉得我几乎关闭了它,但是我的脚本出了问题。任何人都可以帮我解决它吗?

谢谢!

您可以这样做:

 函数gototab(重新加载)
{
window.location.hash =' #TAB2' ;
window.location.reload(true);
}

< a href =pictures.htm#tab2onclick =gototab();>打开标签2< / a>


Just got stuck with one problem. I have a page with Jquery UI tabs. Each tab can be accessed from different page by adding a hash tag to the link and it loads the page with the tab that I need. However, I also need to access different tabs within the same page. What I came up with is to add target="_parent" to the link with hash tag:

<a href="pictures.htm#tab2" target="_parent">

and it does what I need but only in IE. It reloads the page with different hash tag but for some reason Chrome and Firefox load the same tab every time. What I need is to create a javascript function for the link which will fully reload the page with different hash tag.

I came up with this code:

function gototab(reload)
   {
    window.location.href = 'pictures.htm#tab2';
    window.location.reload(true);
   }

<a href="pictures.htm#tab2" onclick="gototab();">open tab 2</a>

I feel like I almost closed it but something is wrong with my script. Can anybody help me to solve it?

Thanks!

解决方案

You can do this:

function gototab(reload)
   {
    window.location.hash = '#tab2';
    window.location.reload(true);
   }

<a href="pictures.htm#tab2" onclick="gototab();">open tab 2</a>

这篇关于用不同的锚点重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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