• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 327
  • Last Modified:

Javascript pop-up window

Hello Experts
I am currently showing a audio file on the webpage in the popup window, using he following
<a href="http://www.chapdav.com/octagonmedia/babies_go/samples/babies_go_beatles_preview/13_norwegian_wood_preview.mp3" onclick="window.open(this.href,'Name a Star','resizable=yes,location=no,location=0,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=300,height=100,status'); return false">Pray</a>

Is there anyway I can make the popup appear in the center of the page, and also remove the address bar?

I have tried but its not working as desired.

Please advise
3 Solutions
you can use window.moveTo(x,y) method to move the window to the desired place.


as far as address bar is concerned modern browsers dont allow hiding the address bar.
Om PrakashCommented:
You can specify the top & left along with width & height.

removal of address bar is already present in the code you currently have.
Ivo StoykovCommented:
for center popup try this
for no address bar try adding toolbar=no,menubar=no


Ivo Stoykov
function centeredDialog(url, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
<a href="javascript:void(0);" onclick="centeredDialog('http://www.nigraphic.com', 'myPop1',400,400);">CLICK TO OPEN POPUP</a>

Open in new window

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


As far as address bar is concerned there is no problem  in your code. The problem is security concerns. If people could hide the address bar, people would be able to recreate login pages such as Paypal and people would be tricked into logging into them and giving a malicious hacker their password.

As a result, most of the latest browsers dont allow hiding the location bar, although in some browsers, setting location=no will disable the address bar from being modified.
Do u want to add it as a layer to a same page? It can be done using a combination of css and javascript
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now