- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2015 02:55 AM
Hi,
Im trying to learn how to have a page that after a few seconds it will redirect to another page. I'm having problem with that setTimeout doesnt wait for the milliseconds I want it to but rather after like 2-3 seconds do the redirect. It doesnt matter if I type in 1 millisecond or 30000 millisecond. It happens at the same time,.
My simple code is this, which I have on a new UI page to see how it works..
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
My text
<script>
setTimeout(redirectNavPage(),10000);
function redirectNavPage()
{
var URL = "/navpage.do";
top.window.location = URL;
}
</script>
</j:jelly>
I put 10000 milliseconds just so I should notice that it's working.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2015 03:12 AM
Well,
I found it myself 😃
I should have setTimeout(redirectNavPage,10000) instead of setTimeout(redirectNavPage(),10000);
if I have the () on the function it will hit instantly... Just if anyone else beside me runs into this 😎
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2015 03:12 AM
Well,
I found it myself 😃
I should have setTimeout(redirectNavPage,10000) instead of setTimeout(redirectNavPage(),10000);
if I have the () on the function it will hit instantly... Just if anyone else beside me runs into this 😎
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2016 02:46 AM
Too bad I can't pass variables now, but at least it explains why it wasn't waiting anymore
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 10:28 AM
Sure you can:
setTimeout(function(){ redirectNavPage(param1, param2, param3); }, 10000);