首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >重定向url

重定向url
EN

Stack Overflow用户
提问于 2013-09-17 08:03:19
回答 2查看 103关注 0票数 0

在下面的代码中,我在搜索我的url之前搜索一个数据,我的url将在coursemaster_site中,而当我搜索它时,它将在coursemaster_site/index1中,当我关闭搜索结果时,url将在coursemaster_site /coursemaster_site中,但是我希望在关闭搜索结果之后,url位于coursemaster_site中。

controller:coursemaster_site

代码语言:javascript
复制
function index1()
    {
        $data            = array();
        $keyword         = $this->input->post('keyword');
        if($keyword!=""){
            $data['results'] = $this->coursemaster_model->search($keyword);
        }
        $this->load->view('coursemaster_view', $data);

    }

view:coursemaster_view

代码语言:javascript
复制
<form action="<?php echo site_url('coursemaster_site/index1');?>" method = "post">
<br/><center>SEARCH:<input type="text" name = "keyword" required/>
<input type="submit" name="submit" id="opn" value = "Search"  onClick="hide1('hiddendiv')"  class="btn-success btn" /></center>
</form>

<?php
if (isset($_POST['submit'])) { // Here
  // Do the search here
        if($results){
         ?> <div id='hideme'>
         CLOSE<a href='coursemaster_site' class='close_notification' title='Click to Close'>
        <img  src="<?php echo base_url('img/close.png'); ?>" width="15" height="15" alt="Close"    onClick="hide('hideme')"/>
        </a><div style="background:#FFFFFF; width:1000px; height: 540px; position: absolute; left: 20%; top: 35%; margin-left: -100px; margin-top: -120px" id="modal"  >
       <table class="display2 table table-bordered table-striped" id='results'>
       <tr>
            <th>course_code</th>
            <th>course name</th>
       </tr>
       <tr><?php
             foreach ($results as $row) {
      ?>
       <td><?php echo $row->course_code;?></td>
       <td><?php echo $row->course_name;?></td>
       </tr>
            <?php
            } 
        }else{
        echo"<div id='hideme'>
         CLOSE<a href='coursemaster_site' class='close_notification' title='Click to Close'>";
        echo "<div id='modal' style='background:#FFFFFF; width:1000px; height: 525px; position: absolute; left: 20%; top: 35%; margin-left: -100px; margin-top: -110px'>";
        }
  echo"no results";
  echo'</div>';
echo '</div>';        }
 // If closing
?>
</table>
</div></div>
<script>
$('a.modal').bind('click', function(event) { 
        event.preventDefault();
        $('#modal').fadeIn(10);

    });
    function hide(obj) {
        var el = document.getElementById(obj);
        el.style.display = 'none';
    }
    function hide1(obj) {
        var el = document.getElementById(obj);
        el.style.display = 'none';
    }
    </script>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-09-17 08:19:47

改为:

代码语言:javascript
复制
<div id='hideme'>CLOSE
 <a href='/coursemaster_site' class='close_notification' title='Click to Close'> 
...

两处都有。前面的斜杠使href从根开始。

票数 0
EN

Stack Overflow用户

发布于 2013-09-17 08:10:51

执行下列更改并检查其是否有效:

代码语言:javascript
复制
<div id='hideme'>
     CLOSE<a href='javascript:void(0);' class='close_notification' title='Click to Close'>";
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18844446

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档