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

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

Barbara Streisand
Release: 2024-10-26 00:38:27
Original
1068 people have browsed it

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>
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template