[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

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