BaH*_*Øub 3 javascript php redirect blade laravel-4
我正在尝试使用javascript和刀片引擎编写一个简单的重定向,这是我想要做的一个例子:
javascript代码:
<p>Click the button to go to the home page</p>
<button onclick="myFunction()">Click me</button>
<p id="demo"></p>
<script>
function myFunction()
{
var x;
var r=confirm("Are you sure you want to leave this page ?");
if (r==true)
{
//Redirect to home
}
else
{
//stay here
}
document.getElementById("demo").innerHTML=x;
}
</script>
Run Code Online (Sandbox Code Playgroud)
当我使用return时Redirect::route('home')
它不起作用,这样做的正确语法是什么,抱歉我的英语不好.
$ URL =网址::到( '富'); //任何其他路由名称,如home,或使用URL :: route()
<script>
function myFunction()
{
var x;
var r=confirm("Are you sure you want to leave this page ?");
if (r)
{
window.location="{{URL::to('home')}}";
}
...
Run Code Online (Sandbox Code Playgroud)
更多信息:http://laravel.com/docs/routing