Johny
Johny

Reputation: 175

Javascript not displaying popup

I want to make a pop up window appear on the center of the screen,however when i use marginTop property the window does not appear.If remove marginTop property it appears always on upper left side corner. I use php 5.4 . What am I doing wrong?

function show_popup(id) {
        if (document.getElementById){
            obj = document.getElementById(id);

            if (obj.style.display == "none") {
               obj.style.marginTop = 20%;  //if i remove this line it works 
               obj.style.display = "";

            }
        }

    }

Upvotes: 0

Views: 42

Answers (3)

Pranay Rana
Pranay Rana

Reputation: 176896

I think you need to apply "20%" for that like as below

obj.style.marginTop = "20%"; 

Check Syntax over here Style marginTop Property

Upvotes: 1

SQLGuru
SQLGuru

Reputation: 1099

trying wrapping your 20% in single quotes....

like this: '20%'

Upvotes: 1

Romain Linsolas
Romain Linsolas

Reputation: 81617

Did you try to set obj.style.marginTop = "20%" (with the ") ?

Upvotes: 1

Related Questions