【问题标题】:Grocery Crud url redirection via javascriptGrocery Crud url 重定向通过 javascript
【发布时间】:2016-07-28 11:31:34
【问题描述】:

我正在尝试在编辑屏幕上的保存按钮上对杂货杂货使用自定义重定向。我可以使用 URL 片段成功重定向,如下例所示:

$the_catalogue_id = $this->uri->segment(count($this->uri->segments));    
$this->grocery_crud->set_lang_string('update_success_message',
             'Your data has been successfully stored into the database.<br/>Please wait while you are redirecting to the list page.
             <script type="text/javascript">
              window.location = "'.base_url('catalogues/edit').'/'.$the_catalogue_id.'";
             </script>
             <div style="display:none">'
        );

我现在需要将 window.location.hash 添加到重定向 URL 的末尾,但似乎无法正常工作。这是我到目前为止所拥有的:

$this->grocery_crud->set_lang_string('update_success_message',
         'Your data has been successfully stored into the database.<br/>Please wait while you are redirecting to the list page.
         <script type="text/javascript">
         var thehash = window.location.hash
          window.location = "'.base_url('catalogues/edit').'/'.$the_catalogue_id.'"#"+thehash";
         </script>
         <div style="display:none">'
    );

如何将哈希变量添加到重定向 URL 的末尾?

【问题讨论】:

    标签: javascript php codeigniter grocery-crud


    【解决方案1】:

    "+thehash" 中删除双引号。

    连接运算符和变量在生成的 javascript 中不应使用双引号。

       var thehash = window.location.hash;
       window.location = "'.base_url('catalogues/edit').'/'.$the_catalogue_id.'#"+thehash;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-16
      • 2022-07-07
      • 1970-01-01
      相关资源
      最近更新 更多