javascript 单击重定向到 codeigniter 控制器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11015758/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 11:49:48 来源:igfitidea点击:
Redirect on click to the codeigniter controller
提问by Fox
I am trying to redirect a user to a page when he clicks a div. I wanted to know how doI redirect the user to the CI's new controller from the html view?
我试图在用户单击 div 时将用户重定向到页面。我想知道如何从 html 视图将用户重定向到 CI 的新控制器?
Thank YOu
谢谢
回答by Prasenjit Kumar Nag
Add the following code in your html view,
在你的 html 视图中添加以下代码,
$(function(){
$('#div_id').on('click',function(){
window.location.href = "<?php echo site_url('new_controller'); ?>";
});
});
Do change the div_id
and new_controller
to suit your need.
请更改div_id
和new_controller
以满足您的需要。