How to open a new window when clicking a hyperlink?

后端 未结 6 1405
青春惊慌失措
青春惊慌失措 2020-12-18 13:37

I would like to open a new window with height of 600px and width of 200px, after clicking on a hyperlink.

How can I do that in HTML/Javascript?

Do I use some

6条回答
  •  再見小時候
    2020-12-18 14:16

    var user_window=window.open('http://www.someplace.com','someplace_window_name','toolbar=no,directories=no,location=no,status=yes,menubar=no,resizable=yes,scrollbars=yes,width=1024,height=768');
    user_window.focus();
    

    A user click should initiate this, or it will be blocked by most popup blockers. This works in all browsers I've had to support including IE6+, FF, Opera, Safari.

    The focus bit ensures that the new window is brought to the front.

    As an alternative to a popup window, I'd suggest the Dialog plugin for Jquery.
    That's what I replaced 90% of my popup windows with.
    Your popup becomes a popover (bound within the original window), and this as far as I can tell is never blocked by a popup blocker. The Dialog plugin allows dragable popovers, appearance and disappear effects, and lots of other cool stuff.

提交回复
热议问题