• 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
statement
<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
Thanks
0
charlie324
Asked:
charlie324
3 Solutions
 
mayank_joshiCommented:
you can use window.moveTo(x,y) method to move the window to the desired place.

http://www.w3schools.com/jsref/met_win_moveto.asp

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

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

HTH

Ivo Stoykov
<script>
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);
}
</script>
<a href="javascript:void(0);" onclick="centeredDialog('http://www.nigraphic.com', 'myPop1',400,400);">CLICK TO OPEN POPUP</a>

Open in new window

0
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.

 
mayank_joshiCommented:

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.
0
 
wdfdo1986Commented:
Do u want to add it as a layer to a same page? It can be done using a combination of css and javascript
0
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