Home  >  Article  >  Web Front-end  >  How to Customize Window Dimensions When Using target=\"_blank\" in HTML?

How to Customize Window Dimensions When Using target=\"_blank\" in HTML?

Barbara Streisand
Barbara StreisandOriginal
2024-10-26 00:38:27991browse

How to Customize Window Dimensions When Using target=

Opening a New Window with Custom Dimensions in HTML for Target="_blank"

When using target="_blank" in HTML to open a new window, users may face limitations in setting specific dimensions. In this scenario, JavaScript can be leveraged to provide a customizable solution.

To create a new window with specified width and height, use the following code:

<code class="html"><a href="http://www.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>

The window.open() method takes several parameters:

  • this.href: The URL of the target page
  • 'mywin': A unique name for the new window
  • 'left=20,top=20': Coordinates to position the window on the screen
  • 'width=500,height=500': Dimensions of the new window
  • 'toolbar=1': Whether to display a toolbar in the new window
  • 'resizable=0': Whether to allow resizing of the new window

By adjusting these parameters, you can create a custom window that opens on a new page with the desired dimensions.

The above is the detailed content of How to Customize Window Dimensions When Using target=\"_blank\" in HTML?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn