我正在尝试在编辑屏幕上的保存按钮上使用杂货店上的自定义重定向。我可以使用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添加到重定向网址的末尾,但似乎无法使其正常工作。这就是我到目前为止所做的:
$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">'
);
如何将哈希变量添加到重定向网址的末尾?
答案 0 :(得分:1)
从"+thehash"
删除双引号。
连接运算符和变量不应该在生成的javascript中用双引号。
var thehash = window.location.hash;
window.location = "'.base_url('catalogues/edit').'/'.$the_catalogue_id.'#"+thehash;