How can I open a popup window with a fixed size using the HREF tag?

How can I open a popup window with a fixed size using the HREF tag?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Controlling Popup Behavior with the HREF Tag

You have a standard link structure pointing to rentals_popup.php, but you need the browser to treat that target as a constrained modal dialog rather than a new tab or window. Specifically, you want to enforce fixed dimensions, disable the maximize button, and ensure the user cannot accidentally lose context by clicking away. The HTML <a> tag itself has very limited capabilities for controlling these behaviors; it primarily serves as a navigation instruction. To achieve the specific constraints of fixed size and disabled maximization, you must rely on attributes that trigger browser-level window handling logic.

The most direct way to force a popup with specific dimensions using an <a> tag is by utilizing the target attribute combined with window features. You can append parameters directly to the link or construct the href value to include these features if you are dealing with a script that handles the opening logic, but for a standard HTML anchor, the target attribute is your primary lever.

To open the page in a new window or tab while enforcing size constraints, you typically use the target="_blank" attribute alongside a specific window object configuration. However, modern browsers have significantly hardened their security model regarding popups triggered directly by user clicks on links to prevent abuse. Simply adding width=300 and height=400 to a standard <a href="..."> tag will often be ignored or cause the browser to open the link in a new tab at its default size, regardless of the dimensions specified in the HTML attributes.

If you strictly require the window to open with fixed dimensions and specific UI controls disabled (like the maximize button), relying solely on the href attribute within an <a> tag is insufficient for modern browsers. The standard approach involves using JavaScript to intercept the click event or utilizing a specific target setup that respects window features strings, though this is often deprecated in favor of inline scripts for better control over the window.open() arguments.

A more robust solution that adheres to current browser standards while maintaining the HTML structure you provided involves modifying the link generation logic to include a target attribute that points to a name or allows passing features, but this requires the server-side code to construct the URL correctly. You might consider using a dedicated modal library or a simple JavaScript handler attached to the anchor element to call window.open() with the necessary arguments.

Here is how you can modify your PHP logic to use window.open directly when the link is clicked, ensuring the fixed size and disabled maximize button:

// Instead of generating a standard href, attach an onclick event
$onclick = "window.open('rentals_popup.php?id={$row->rentals_id}', '_blank', 'width=600,height=400,resizable=no,menubar=no,toolbar=no,status=no,location=no,scrollbars=yes,dir=ltr')";

$contact_url = '<a href="#" onclick="' . $onclick . '; return false;">Contact</a>';

This approach explicitly defines the window features: width and height set the fixed size, while resizable=no prevents resizing (which effectively disables the maximize behavior by locking dimensions). The menubar, toolbar, status, and location are set to no to minimize distractions, though note that modern browsers often ignore these flags for security reasons regarding popup blockers.

The trade-off here is that you lose the convenience of a direct href navigation flow, forcing users to rely on JavaScript execution. If your environment supports it, consider using a framework like Laravel with its asset management or Blade directives to handle such interactions more cleanly, ensuring that any external resources referenced in your application are served securely via trusted domains. For further reading on secure window opening practices and modern browser security implications, you might explore resources available at https://laravelcompany.com regarding frontend security best practices.

Our network