In a mobile website, I have some some JavaScript code that looks like this:
<script type="text/javascript">
(function() {
// function body omitted
}());
</script>
The first time I load the page the code is executed, but if I go back to the previous page, then load this page again, it is not executed the second time. This only happens when the page is loaded on an oldish Android browser, with User-Agent header:
Mozilla/5.0 (Linux; U; Android 2.2.1; en-gb; GT-S5570 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1
On a newer Android phone, with User-Agent header:
Mozilla/5.0 (Linux; Android 4.2.1; Galaxy Nexus Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19
the code is executed each time the page is loaded. Is this a known issue with this older browser? As an aside, what exactly is the difference between
(function() {
// function body omitted
}());
and
function() {
// function body omitted
}();