Javascript if (j === null) do nothing

I am using CurvyCorners to make my corners curved in IE, the only thing is that when it reads the CSS it takes all the webkit properties and shows me a warning curvyCorners.alert("No object with ID " + arg + " exists yet.\nCall curvyCorners(settings, obj) when it is created.");

.

How can I just set an if statement to do nothing?

if (j === null)
  do nothing(); //but in real script

      

Thanks:)

+2


a source to share


4 answers


Do you have access to the code? If so, you can add this code to the top of the curvyCorners function definition:

if (!obj) return;

      



This will silence the curvyCorners function if the item doesn't exist.

+8


a source


I would recommend

if (j !== null) doSomething();

      



And Kooilnc is probably correct: curvyCorners is probably saying it can't find the element because the DOM hasn't finished loading yet. I would fight this problem with

window.onload = function()
{
    var obj = document.getElementById("corneredObj");

    if (obj !== null) {
        curvyCorners(settings, obj);
    }
}

      

+2


a source


I used this

if (j === null)
   1=1;

      

+2


a source


It might be an idea to call the script after the DOM has loaded. In most cases, you can achieve this by placing a script tag at the bottom of your html document, just before the closing body ( </body>

) tag .

+1


a source







All Articles