Skip to content

newWin(url, title, target='') - Merciglobal Cloud ERPΒΆ

This document explains the newWin() JavaScript utility function provided in Merciglobal Cloud ERP, which is used to open a new browser window or tab, depending on the specified parameters. It also handles scenarios where pop-ups might be blocked by the user's browser and informs the user accordingly.


PurposeΒΆ

The newWin() function is designed to programmatically open a new window or tab for performing specific tasks or navigating to external/internal pages from within the Merciglobal ERP system interface.


Function SignatureΒΆ

newWin(url, title, target = '')

Parameters:ΒΆ

Parameter Type Description
url string The URL to be opened in the new window.
title string Title or name assigned to the new window.
target string Optional target (_blank, custom name). Defaults to empty string.

How It WorksΒΆ

  • Utilizes window.open() to attempt opening the desired URL.
  • Detects whether the pop-up window was successfully opened.
  • If blocked by the browser, it shows a warning message to the user.

Successful Case:ΒΆ

If the browser allows pop-ups:

const win = window.open(url, target || title);
- The new window opens as expected.

Blocked Case:ΒΆ

If the new window fails to open (most likely blocked by browser pop-up settings):

if (!win || win.closed || typeof win.closed == 'undefined') {
  alert('Pop-up was blocked. Please allow pop-ups for this site.');
}
- Displays a clear alert message to the user.

Example UsageΒΆ

newWin('https://support.mercicloud.com', 'Merci Support');
This will open the support page in a new window. If blocked, the user is warned to allow pop-ups.

Notes on Browser BehaviorΒΆ

  • Many modern browsers block pop-ups triggered outside user interaction (like clicks).
  • Ensure that newWin() is called from a user-initiated event to avoid being blocked.

πŸ› οΈ Use Cases in Merciglobal Cloud ERPΒΆ

  • Opening external documentation
  • Loading printable views or reports
  • Previewing invoices or quotations
  • Accessing third-party integrated systems

Always ensure that critical operations which rely on new windows being opened are paired with user interactions for better compatibility and user experience.