Kevin
Kevin

Reputation: 7309

Javascript not functioning unless developer tools running

I have the following button:

<input type="button" value="Reset" onclick="reset();" ID="btnReset" class="button textButton" style="bottom:8px; right:8px;" />

The reset function looks like this:

function reset() {
    try {
        alert('working');
        front = document.getElementById("hdnFrontBack").value === "true";
        if (!front) {
            front = true;
            myimage.src = myimage.src.substring(0, myimage.src.length - 4);
        }
        myimage.style.height = defHeight;
        if (myimage.naturalWidth != 0)
            currentZoom = defHeight / myimage.naturalHeight;
        document.getElementById("hdnFrontBack").value = front;
    }
    catch (exp) {
        alert(exp);
    }
}

This button does nothing when I first load the page.
In IE11 it will start working as soon as I launch developer tools (F12) and continue working after that even if I close developer tools.
In Chrome, it will only work as long as I have developer tools running.

Does anyone have any idea what would cause this?

Upvotes: 1

Views: 78

Answers (1)

Lee Taylor
Lee Taylor

Reputation: 7994

I believe reset is a pre-existing function so the javascript engine is getting confused. Rename reset to something else and I believe your problem will disappear.

Upvotes: 2

Related Questions