4D Blog

Home Product Use an offscreen web area

Use an offscreen web area

June 9, 2020

Product

Do you need to load web pages, extract metadata, or generate pictures from the contents of pages on a headless server? If you answered “yes”, then you’re in luck because 4D v18 R3 makes it possible! Now you can create an offscreen web area with the WA Run offscreen area command. 

4D allows you to use a web area in offscreen mode. The HDI below shows you how to use it with a JavaScript API as a Google chart:

HDI offscreen web area

The WA Run offscreen area command creates a web area in memory. You need to pass all the useful information for the web area in parameter, such as:

  • The URL to load
  • The area name
  • The callback method called when an event is thrown by the web area

For example, if you want to get the title of the last 4D blog post, you need to load the “https://blog.4d.com” URL:

$params:=New object
// url of the html file with the js function to use
$params.url:="https://blog.4d.com"

// Add a callback method called on event
$params.onEvent:=Formula(GetBlogTitle )

// create offscreen web area according to $params
$title:=WA Run offscreen area($params)

And use this code in the callback method, GetBlogTitle:

If (FORM Event.code=On End URL Loading)
  $js:="document.getElementsByTagName('h2')[1].getElementsByTagName('a')[0].innerHTML"
  This.result:=WA Evaluate JavaScript(*;This.area;$js)
End if 

To make debugging easy with an offscreen web area,  we added a new command: WA OPEN WEB INSPECTOR. It opens the web inspector and allows you to verify whether or not the page is correctly loaded, or if your JavaScript code throws an error.

You can refer to the documentation to see in detail what you can do with these new commands.

Discuss

Tags Programming, v18 R3, v19, Web

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy