Home >Web Front-end >CSS Tutorial >How to Open a Custom-Sized Pop-Up Window with JavaScript?
Pop-Up a New Window with Custom Dimensions
In web development, sometimes it's desirable to open a new window for a specific purpose, such as sharing content on a social media platform. However, using target="_blank" might not provide the desired customization options regarding the new window's dimensions and behavior.
To control these aspects, JavaScript can be leveraged to achieve the desired outcome. Consider the following code snippet:
<code class="html"><a href="facebook.com/sharer" onclick="window.open(this.href, 'mywin', 'left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;">Share this</a></code>
This code achieves the following:
The above is the detailed content of How to Open a Custom-Sized Pop-Up Window with JavaScript?. For more information, please follow other related articles on the PHP Chinese website!