Auto Reload
<br />
I did some research and it appears to have been sourced from <a class='bbc_url' href='http://www.eclipse.org/forums/index.php/mv/tree/163879/#page_top'>http://www.eclipse.org/forums/index.php/mv/tree/163879/#page_top</a> (Jason Weathersby) which is probably an updated version of <a class='bbc_url' href='http://www.birt-exchange.org/org/devshare/designing-birt-reports/69-periodically-reload-birt-report/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/69-periodically-reload-birt-report/</a> (Virgil)<br />
<br />
The Jason?s version is obviously simpler than Virgil?s, but JSLint is less than happy with the Jason?s JavaScript<br />
<br />
I cleaned it up some, JSLint is happier, but not content; and mine remains a rework of a generations old solution.<br />
<br />
Suggestions for a fresh approach, or rework to make JSLint happy would be appreciated. <br />
<br />
<br />
<strong class='bbc'>Legacy Version</strong><br />
<em class='bbc'>With URL ending ?ReportName.rptdesign &__overwrite=true?</em><br />
<form name="input" onSubmit="return reloadPage();"><br />
<br />
<script type="text/javascript"><br />
<br />
function reloadPage() {<br />
var targetURL = new String(location.href);<br />
location.replace(targetURL);<br />
return false;<br />
}<br />
<br />
timer=setTimeout('reloadPage()', 60000);<br />
</script><br />
<br />
<br />
<br />
<strong class='bbc'>My Version</strong><br />
<em class='bbc'>Without URL Parameters</em><br />
<form name="input" onSubmit="return reloadPage();"><br />
<br />
<script type="text/javascript"><br />
<br />
<br />
function reloadPage() {<br />
'use strict';<br />
location.reload(true);<br />
}<br />
<br />
timer = setTimeout(reloadPage, 60000);<br />
</script>
Comments
-
I reworked your code a little bit. It's working for me in BIRT 3.7.2 and JSLint didn't give me any errors with it either.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
<html>
<body>
<script type="text/javascript">
/*global setTimeout*/
/*global location*/
/*global document*/
'use strict';
function reloadPage() {
location.reload(true);
}
var timer;
timer = setTimeout(reloadPage, 60000);
document.getElementById("input").onsubmit = function () {
reloadPage();
};
</script>
<form name="input">
</form>
</body>
</html>
</pre>Warning No formatter is installed for the format ipb0 -
setTimeout() and setInterval() functions allow you to execute a piece of JavaScript code/function at a certain point in the future. setInterval repeats the call, setTimeout only runs it once.
setTimeout(expression, timeout); runs the code/function once after the timeout. It is a time based code execution method that will execute script only one time when the interval is reached, and not repeat again unless you gear it to loop the script by nesting the setTimeout object inside of the function it calls to run. If geared to loop, it will keep firing at the interval unless you call clearTimeout(). If you want something to happen one time after some seconds Then use setTimeout... because it only executes one time when the interval is reached.
setTimeout(function() {
console.log('Wait 3 seconds and I appear just once');
}, 3000);
setInterval(expression, timeout); runs the code/function repeatedly, with the length of the timeout between each repeat. It is a time interval based code execution method that has the native ability to repeatedly run specified script when the interval is reached. It should not be nested into its callback function by the script author to make it loop, since it loops by default. It will keep firing at the interval unless you call clearInterval(). If you want to loop code for animations or clocks Then use setInterval.
setInterval(function() {
console.log('Every 3 seconds I appear on your console');
}, 3000)
0
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 150 General Questions
- 148 Thrust Services
- 57 OpenText Hackathon
- 37 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 186 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 8 XM Fax
- Follow Categories