<head>
<script type="text/javascript">
<!--
function Redirect()
{
window.location="http://www.newlocation.com";
}
document.write("You will be redirected to main page in 10 sec.");
setTimeout('Redirect()', 10000);
//-->
</script>
</head>
1.Here my question is inside settimeout method how can we use a function to call,if we use string literal inside the single quotes i think that is represent to write the exact result like document.write("hello");
now the result will be as it is inside the string..how javascript can understand that setTimeout('Redirect()', 10000);
'redirect()' as a method ,instead of writing the it as is..
<head>
<script type="text/javascript">
<!--
function Redirect() {
window.location="http://www.tutorialspoint.com";
}
document.write("You will be redirected to our main page in 10 seconds!");
setTimeout(Redirect(), 10000);
//-->
</script>
</head>
<body>
</body>
</html>
2.When i do like this as setTimeout(Redirect(), 10000);
,it is not working ...it starts to redirect the page directly instead using that settimeout it...