Skip to content

IOptionalBrowserSettings

David Ortner edited this page Mar 20, 2024 · 4 revisions

IOptionalBrowserSettings represents the settings of the browser sent to the constructor.

Signature

interface IOptionalBrowserSettings

Example

import { Browser } from "happy-dom";

const browser = new Browser({
    settings: {
        navigator: : {
           userAgent: "Mozilla/5.0 (X11; Linux x64) AppleWebKit/537.36 (KHTML, like Gecko) HappyDOM/2.0.0"
        }
    }
});

Properties

Property Type Description
disableJavaScriptEvaluation? boolean Disables JavaScript evaluation.
disableJavaScriptFileLoading? boolean Disables JavaScript file loading.
disableCSSFileLoading? boolean Disables CSS file loading.
disableComputedStyleRendering? boolean Disables computed style rendering.
handleDisabledFileLoadingAsSuccess? boolean Set to "true" to trigger a load event instead of an error event when file loading is disabled.
errorCapture? BrowserErrorCaptureEnum Error capturing policy.
navigation.disableMainFrameNavigation? boolean Disables navigation to other pages in the main frame or a page.
navigation.disableChildFrameNavigation? boolean Disables navigation to other pages in child frames (such as iframes).
navigation.disableChildPageNavigation? boolean Disables navigation to other pages in child pages (such as popup windows).
navigation.disableFallbackToSetURL? boolean Disables the fallback to setting the URL when navigating to a page is disabled or when inside a detached browser frame.
navigation.crossOriginPolicy? BrowserNavigationCrossOriginPolicyEnum Sets the policy for cross-origin navigation.
navigator.userAgent? string User agent.
navigator.maxTouchPoints? number Max touch points.
device.prefersColorScheme? string Prefers color scheme.
device.mediaType? string Media type.
Clone this wiki locally