title: Laravel 4- redirect to a route inside javascript code Blade template
body: <p>I'm trying to write a simple redirection using javascript and blade engine, and this is an example of what i want to do:</p>
  
  <p>javascript code:</p>
  
  <pre><code>&lt;p&gt;Click the button to go to the home page&lt;/p&gt;
  
  &lt;button onclick="myFunction()"&gt;Click me&lt;/button&gt;
  
  &lt;p id="demo"&gt;&lt;/p&gt;
  
  &lt;script&gt;
  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;
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>when i use return <code>Redirect::route('home')</code> it does not work, what is the right syntax to do that, and sorry for my bad english.</p>