Question : Error string in catch block?

i have the following code which show error from a string when there is a error

is there any way that i can make this in catch block?

main()
{
if (a==1)
{
 string = "error1"
}
elseif (a==2)
{
 string = "error2"
}
}
catch (e)
{


}


Like below:


i have the following code which show error from a string when there is a error

is there any way that i can make this in catch block?
main()
{
}

catch (e)
{

if (a==1)
{
 string = "error1"
}
elseif (a==2)
{
 string = "error2"
}

}

Answer : Error string in catch block?

A quick google gives me this for looking up an element's left and top properties:

========

function getElementLeft(Elem) {
      if (ns4) {
            var elem = getObjNN4(document, Elem);
            return elem.pageX;
      } else {
            var elem;
            if(document.getElementById) {
                  var elem = document.getElementById(Elem);
            } else if (document.all){
                  var elem = document.all[Elem];
            }
            xPos = elem.offsetLeft;
            tempEl = elem.offsetParent;
              while (tempEl != null) {
                    xPos += tempEl.offsetLeft;
                    tempEl = tempEl.offsetParent;
              }
            return xPos;
      }
}


function getElementTop(Elem) {
      if (ns4) {
            var elem = getObjNN4(document, Elem);
            return elem.pageY;
      } else {
            if(document.getElementById) {      
                  var elem = document.getElementById(Elem);
            } else if (document.all) {
                  var elem = document.all[Elem];
            }
            yPos = elem.offsetTop;
            tempEl = elem.offsetParent;
            while (tempEl != null) {
                    yPos += tempEl.offsetTop;
                    tempEl = tempEl.offsetParent;
              }
            return yPos;
      }
}

======

After that, you can set another element's position like so:

======

document.getElementById("movetext").style.left = pos1;
document.getElementById("movetext").style.top = pos2;
Random Solutions  
 
programming4us programming4us