$url=URL::to('foo'); // any other route name, like home, or use 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')}}";
}
...
More info: http://laravel.com/docs/routing