【问题标题】:Twitter Bootstrap: open nav-tabs using script from phpTwitter Bootstrap:使用 php 脚本打开导航选项卡
【发布时间】:2017-05-05 03:46:33
【问题描述】:

是否可以使用 php 文件中的脚本打开导航选项卡(php 文件是外部文件)。我尝试使用这个echo "<script>alert('success')open('colors.php#yellow','_self')</script>"; 指向页面,它将打开一个带有黄色 ID 的导航选项卡

我有这个 HTML

<div class="container">

<!-------->
<div id="content">
    <ul id="tabs" class="nav nav-tabs" data-tabs="tabs">
        <li class="active"><a href="#red" data-toggle="tab">Red</a></li>
        <li><a href="#orange" data-toggle="tab">Orange</a></li>
        <li><a href="#yellow" data-toggle="tab">Yellow</a></li>
        <li><a href="#green" data-toggle="tab">Green</a></li>
        <li><a href="#blue" data-toggle="tab">Blue</a></li>
    </ul>
    <div id="my-tab-content" class="tab-content">
        <div class="tab-pane active" id="red">
            <h1>Red</h1>
            <p>red red red red red red</p>
        </div>
        <div class="tab-pane" id="orange">
            <h1>Orange</h1>
            <p>orange orange orange orange orange</p>
        </div>
        <div class="tab-pane" id="yellow">
            <h1>Yellow</h1>
            <p>yellow yellow yellow yellow yellow</p>
        </div>
        <div class="tab-pane" id="green">
            <h1>Green</h1>
            <p>green green green green green</p>
        </div>
        <div class="tab-pane" id="blue">
            <h1>Blue</h1>
            <p>blue blue blue blue blue</p>
        </div>
    </div>
</div>

PHP open_color.php

echo "<script>alert('success')open('colors.php#yellow','_self')</script>"

我的输出仍然是红色标签将打开为活动状态

【问题讨论】:

    标签: php jquery html twitter-bootstrap


    【解决方案1】:

    这个呢:

    open_color.php:

    $val = $_REQUEST['some_var'];
    
        switch ($val) {
            case 'red':
                header("Location: colors.php#red");
                break;
    
            . . .
    
            default:
                header("Location: colors.php");
                break;
        }
    

    【讨论】:

    • 感谢您的回答先生,但即使Location 代码也无法正常工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-10-01
    • 1970-01-01
    • 2013-01-21
    • 2013-05-03
    • 2020-03-14
    • 2023-03-29
    • 2013-08-01
    相关资源
    最近更新 更多