使用 window.location.reload(url) 重新加载页面后未选择 jquery 选项卡

发布于 2024-11-05 06:00:17 字数 1791 浏览 5 评论 0原文

当我单击页面上的刷新按钮时,重新加载的页面似乎没有像通常刷新或重新加载页面那样选择第一个选项卡?

我的 jquery 选项卡的设置与您通常在任何地方找到的一样。

有什么想法吗?

<head>
    <script type="text/javascript" src="js/jquery-1.4.2.js"></script>
</head>

选项卡

<div class="tabs">
    <ul class="tabNavigation">
        <li><a href="#priority">Priority</a></li>
        <li><a href="#urgent">Urgent</a></li>
        <li><a href="#potential">Potential</a></li>
        <li style="margin-left:75px">&nbsp;</li>
    </ul>
    <div id="priority">
    </div>
    <div id="urgent">
    </div>
    <div id="potential">
    </div>
</div>

按钮调用

 <input type="button" id="btnRefresh" value="Refresh" onclick="do_refresh()"/>

do_refresh函数

function do_refresh()
{
var man_num = document.getElementById('txtOpCode').value;
var ps=document.getElementById('drpSect').value;
var url = "auto.php?v=l&man_num="+man_num+"&ps="+ps;
window.location.reload(url);        
}

jQuery选项卡函数

<script type="text/javascript" charset="utf-8">
$(function () {
  var tabContainers = $('div.tabs > div');
  tabContainers.hide().filter(':first').show();
  $('div.tabs ul.tabNavigation a').click(function () {
    tabContainers.hide();
    tabContainers.filter(this.hash).show();
    $('div.tabs ul.tabNavigation a').removeClass('selected');
          $(this).addClass('selected');
     return false;
    }).filter(':first').click();
        });
</script>

When I click a refresh button on my page the page that reloads doesn't seem to be selectiung the first tab as it usually does with a refresh or reload page?

My jquery tabs are set up as you'd normally find anywhere.

Any ideas?

<head>
    <script type="text/javascript" src="js/jquery-1.4.2.js"></script>
</head>

tabs

<div class="tabs">
    <ul class="tabNavigation">
        <li><a href="#priority">Priority</a></li>
        <li><a href="#urgent">Urgent</a></li>
        <li><a href="#potential">Potential</a></li>
        <li style="margin-left:75px"> </li>
    </ul>
    <div id="priority">
    </div>
    <div id="urgent">
    </div>
    <div id="potential">
    </div>
</div>

Button call

 <input type="button" id="btnRefresh" value="Refresh" onclick="do_refresh()"/>

do_refresh function

function do_refresh()
{
var man_num = document.getElementById('txtOpCode').value;
var ps=document.getElementById('drpSect').value;
var url = "auto.php?v=l&man_num="+man_num+"&ps="+ps;
window.location.reload(url);        
}

jQuery tabs function

<script type="text/javascript" charset="utf-8">
$(function () {
  var tabContainers = $('div.tabs > div');
  tabContainers.hide().filter(':first').show();
  $('div.tabs ul.tabNavigation a').click(function () {
    tabContainers.hide();
    tabContainers.filter(this.hash).show();
    $('div.tabs ul.tabNavigation a').removeClass('selected');
          $(this).addClass('selected');
     return false;
    }).filter(':first').click();
        });
</script>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

情深已缘浅 2024-11-12 06:00:17

好吧,我改变了它的工作方式,我想在动态创建它之前尝试在重新加载时显示为选项卡部分。我现在已经删除了它,并且 jquery 现在似乎可以正常加载。因此,用户必须从下拉列表中选择一个选项,但目前还可以。

Ok I changed the way this works and I was trying to display as tab section on reload I think before it had been dynamically created. I've now removed that and jquery appears to be loading ok now. So the user will have to select an option from the dropdown but for now that is ok.

唠甜嗑 2024-11-12 06:00:17
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple tabs</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<style type="text/css">
li{
    float:left;
    margin-left:20px;
}
</style>
</head>

<body>
<script type="text/javascript">
    $(document).ready(function(){
        var myCookie = document.cookie.replace(/(?:(?:^|.*;\s*)test2\s*\=\s*([^;]*).*$)|^.*$/, "$1");

        switch(myCookie){
            case "undefined":
                tab_1();
                break;
            case "tab1":
                tab_1();
                break;
            case "tab2":
                tab_2();
                break;
            case "tab3":
                tab_3();
                break;
        }
    });

    function tab_1(id){
        $('.tab-1cont').show();
        $('.tab-2cont').hide();
        $('.tab-3cont').hide();
        document.cookie = "test2="+id;
    }

    function tab_2(id){
        $('.tab-1cont').hide();
        $('.tab-2cont').show();
        $('.tab-3cont').hide();
        document.cookie = "test2="+id;
    }

    function tab_3(id){
        $('.tab-1cont').hide();
        $('.tab-2cont').hide();
        $('.tab-3cont').show();
        document.cookie = "test2="+id;
    }
</script>

<ul>
    <li onclick="tab_1(id)" id="tab1" class="tab_001">Tab-1</li>
    <li onclick="tab_2(id)" id="tab2" class="tab_002">Tab-2</li>
    <li onclick="tab_3(id)" id="tab3" class="tab_003">Tab-3</li>
</ul>

<div style="clear:both"></div>
<div class="tab-1cont"><h1>Tab 1 container</h1></div>
<div class="tab-2cont"><h1>Tab 2 container</h1></div>
<div class="tab-3cont"><h1>Tab 3 container</h1></div>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple tabs</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<style type="text/css">
li{
    float:left;
    margin-left:20px;
}
</style>
</head>

<body>
<script type="text/javascript">
    $(document).ready(function(){
        var myCookie = document.cookie.replace(/(?:(?:^|.*;\s*)test2\s*\=\s*([^;]*).*$)|^.*$/, "$1");

        switch(myCookie){
            case "undefined":
                tab_1();
                break;
            case "tab1":
                tab_1();
                break;
            case "tab2":
                tab_2();
                break;
            case "tab3":
                tab_3();
                break;
        }
    });

    function tab_1(id){
        $('.tab-1cont').show();
        $('.tab-2cont').hide();
        $('.tab-3cont').hide();
        document.cookie = "test2="+id;
    }

    function tab_2(id){
        $('.tab-1cont').hide();
        $('.tab-2cont').show();
        $('.tab-3cont').hide();
        document.cookie = "test2="+id;
    }

    function tab_3(id){
        $('.tab-1cont').hide();
        $('.tab-2cont').hide();
        $('.tab-3cont').show();
        document.cookie = "test2="+id;
    }
</script>

<ul>
    <li onclick="tab_1(id)" id="tab1" class="tab_001">Tab-1</li>
    <li onclick="tab_2(id)" id="tab2" class="tab_002">Tab-2</li>
    <li onclick="tab_3(id)" id="tab3" class="tab_003">Tab-3</li>
</ul>

<div style="clear:both"></div>
<div class="tab-1cont"><h1>Tab 1 container</h1></div>
<div class="tab-2cont"><h1>Tab 2 container</h1></div>
<div class="tab-3cont"><h1>Tab 3 container</h1></div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文