views:

355

answers:

3

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

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

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

Thanks :)

+4  A: 

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

if (!obj) return;

This will quit the curvyCorners function silently if the element doesn't exist.

Delan Azabani
Thanks, I actually put `return;` in after `if (j === null)` and that did the trick :)
Kyle Sevenoaks
+1  A: 

It may be an idea to call the script after the DOM is loaded. Most of the times you can achieve this by placing the script tag at the bottom of your html document, right before the closing body tag (</body>).

KooiInc
Already done. Thanks.
Kyle Sevenoaks
KooiInc, you could also addEventListener('DOMContentLoaded',...,false) if you want to physically place the code in the head but run it at the end of the DOM loading.
Delan Azabani
A: 

I would recommend

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

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

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

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