gpt4 book ai didi

javascript - 通过 javascript 进行 Grocery Crud url 重定向

转载 作者:行者123 更新时间:2023-11-27 22:42:42 24 4
gpt4 key购买 nike

我正在尝试在编辑屏幕上的保存按钮上对 Grocery 杂物使用自定义重定向。我可以使用 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 的末尾?

最佳答案

"+thehash" 中删除双引号。

在生成的 JavaScript 中,串联运算符和变量不应使用双引号。

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

关于javascript - 通过 javascript 进行 Grocery Crud url 重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38635100/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com