Caption and HTMLRenderer

MiServer is Dyalog's APL-based web development framework

Caption and HTMLRenderer

Postby PGilbert on Thu Aug 13, 2020 2:01 pm

While defining an HTMLRenderer the following example works as described in the documentation and the caption of the form will be 'Title Wins':
      html←'<title>Title Wins!</title>Test'
'hr' ⎕WC 'HTMLRenderer'('HTML' html)('Caption' 'Caption Wins!')('Size' (10 20))

However when using the URL method and loading an HTML file that has no <title> markup the caption of the form will be the name of the file loaded and if there is a <title> markup in the file it will the caption of the form:

      'hr' ⎕WC 'HTMLRenderer'('URL' 'file:///D:\NoTitle.html')('Caption' 'Caption Wins!')('Size' (10 20))

This makes it impossible to load an HTML file and have control over the caption of the resulting form (we write the customer name in the caption of the form in our case with our company logo).

Is this the expected behavior ? In the affirmative is the workaround would be to do a regular form and have the HTMLRenderer specified has a child or there is a better idea ?
User avatar
Posts: 435
Joined: Sun Dec 13, 2009 8:46 pm
Location: Montréal, Québec, Canada

Re: Caption and HTMLRenderer

Postby Brian|Dyalog on Tue Sep 22, 2020 11:55 pm

Hi Pierre,

First, I apologize for not responding earlier. Either the notification of your post didn't arrive in my inbox, or I somehow missed it.

Yes, this is the expected behavior. The caption should really be set with the <title> element. In the absence of a <title> element, Chromium will display the URL of the requested resource; in this case, the file name. That's how browsers work.

Further, you can introduce an incongruity between the displayed caption and what the DOM thinks is the document title. For instance, if you have an HTML file with a <title> element and subsequently set the renderer.Caption property to something else, the DOM thinks the title has not changed. To actually set the caption, and have the DOM be in sync, I would use something like renderer.ExecuteJavaScript 'document.title="My Title"'.

I hope this helps!
User avatar
Posts: 112
Joined: Thu Nov 26, 2009 4:02 pm
Location: West Henrietta, NY

Return to MiServer

Who is online

Users browsing this forum: No registered users and 0 guests