WebExeBuilder Documentation

getCurrentUrl

Category: Browser Control

Namespace: web.browser.getCurrentUrl

Description

Get the URL of the currently loaded page. Returns the full URL including protocol.

Syntax

await web.browser.getCurrentUrl();

Parameters

None

Returns

Promise<string> - Returns the requested string value

Example

Simple example

const url = await web.browser.getCurrentUrl();
console.log('Current URL:', url);

Practical example

const url = await web.browser.getCurrentUrl();
document.getElementById('url-display').textContent = url;

Advanced example

async function updateAddressBar() {
    const url = await web.browser.getCurrentUrl();
    const urlInput = document.getElementById('address-bar');
    
    urlInput.value = url;
    
    // Update navigation button states
    const canGoBack = await web.browser.canGoBack();
    const canGoForward = await web.browser.canGoForward();
    
    document.getElementById('back-btn').disabled = !canGoBack;
    document.getElementById('forward-btn').disabled = !canGoForward;
}

Use Cases

  • Display current URL in address bar
  • Track navigation history
  • Log visited pages
  • Implement URL-based features
  • Check current location
  • Update UI based on URL
  • Save current page location
  • Implement bookmarks
  • web.browser.navigate()
  • web.browser.getPageTitle()

Notes

  • Part of browser control functionality
  • Asynchronous operation
  • Returns promise