In the following function, the first debug output line ("debugPut"), produces what seems like a valid result:

X: 427 Y: 197src=

and even pasting the image link itself correctly displays the screen graphics.
However, the screen never displays and the next debug text which was supposed to print "Kukuriiiiiiku" doesn't seem to print anything - which implies to me that settingsScr never gets triggered.
Any idea what could be causing this?

Many thanks in advance if you try to help!


function handleSettings() //Handles the settings screen
var settingsX = Math.floor((xSize-settingsScr.width)/2); //the centered X location of the settings window
var settingsY = Math.floor((ySize-settingsScr.height)/2); //the centered Y location of the settings window
document.getElementById("debugPut").innerHTML= ("X: "+settingsX+" Y: "+settingsY+"src="+settingsScr.src); // for debug

    settingsScr.onload = function ()        //make sure resource was loaded first
    {                               //shows the bg image only once it was loaded
        document.getElementById("debugPut").innerHTML= ("Kukuriiiiiiku"); // for debug
        document.getElementById("debugPut").innerHTML= ("X2: "+settingsX+" Y: "+settingsY+"src="+this.src); // for debug


Recommended Answers

All 2 Replies

what kind of DOM element is debugPut?

Found the solution: The problem was that by the time the execution got to this function, the item (settingsScr) was already loaded. That way, the onload event didn't fire and the function didn't occur.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.