-1

I have javascript code:

function f_dialogOpen()
{
    var e_window = document.createElement("div");
    e_window.style.position = 'absolute';
    var n_width  = 300;
    var n_height = 200;
    var a_docSize = f_documentSize();
    e_window.style.left = ((a_docSize[0] - n_width)  / 2) + a_docSize[2]) + 'px';
    e_window.style.top  = ((a_docSize[1] - n_height) / 2) + a_docSize[3]) + 'px';
    e_window.style.zIndex = 1002;

    e_window.innerHTML = 'Hello, world!';

    document.body.appendChild(e_window);
}

Function f_documentSize() returns array[4] with widnow size. Here is what I get using firebug:

missing ; before statement
e_window.style.left = ((a_docSize[0] - n_width) / 2) + a_docSize[2]) + 'px';\n

What's wrong?

1 Answer 1

3

Wrong number of brackets:

e_window.style.left = ((a_docSize[0] - n_width)  / 2) + a_docSize[2]) + 'px';
e_window.style.top  = ((a_docSize[1] - n_height) / 2) + a_docSize[3]) + 'px';

You need:

e_window.style.left = (((a_docSize[0] - n_width)  / 2) + a_docSize[2]) + 'px';
e_window.style.top  = (((a_docSize[1] - n_height) / 2) + a_docSize[3]) + 'px';
Sign up to request clarification or add additional context in comments.

1 Comment

actually he may need 3, or it could concatenate instead of add.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.