[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Infinite page reload when using addLoadEvent

htc310.1408

11/2/2014 8:50:00 AM

Hello,

when I use the addLoadEvent with a self developed function (expected to be reload only once when addLoadEvent calls), it seems the page is reloaded endlessly. Anyone out there know the reason and advise a hint to solve the problem?

-------------------------------------------
<script>
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}

function loadImage () {...};

addLoadEvent(loadImage);
</script>

<form action="testing.jsp" method=post>
....
</form>
-------------------------------------------

Any help is apperciated:p



1 Answer

JJ

11/2/2014 1:00:00 PM

0

On Sun, 2 Nov 2014 01:49:36 -0700 (PDT), htc310.1408@gmail.com wrote:
> Hello,
>
> when I use the addLoadEvent with a self developed function (expected to be
> reload only once when addLoadEvent calls), it seems the page is reloaded
> endlessly. Anyone out there know the reason and advise a hint to solve
> the problem?
>
> -------------------------------------------
> <script>
> function addLoadEvent(func) {
> var oldonload = window.onload;
> if (typeof window.onload != 'function') {
> window.onload = func;
> } else {
> window.onload = function() {
> if (oldonload) {
> oldonload();
> }
> func();
> }
> }
> }
>
> function loadImage () {...};
>
> addLoadEvent(loadImage);
> </script>
>
> <form action="testing.jsp" method=post>
> ...
> </form>
> -------------------------------------------
>
> Any help is apperciated:p

None of the provided code can trigger a page reload.
The page reload is likely caused by the other code that aren't provided.