Jump to content

Recommended Posts

  • Moderators

The standard generated index file in smart doesn't contain a link tag for a favicon (something like

<link id="favicon" rel="icon" href="res/favicon.png" type="image/png" sizes="16x16">

However this can be added in code (or add it manually to the default.html file in the template directory, or add it to a Custom Template in the ide)

In code :

procedure TForm1.InitializeForm;
begin
  inherited;
  // this is a good place to initialize components

  var link   := w3_createHtmlElement('link');
  link.id    := 'favicon';
  link.href  := 'res/favicon.png';
  link.rel   := 'icon';
  link.&type := 'image/png';
  link.sizes := '16x16';
  browserapi.document.getElementsByTagName('head')[0].appendChild(link);
end;

If you want to change the icon later on, you can do that too

procedure TForm1.W3Button1Click(Sender: TObject);
begin
  var favicon := browserapi.document.getElementById('favicon');
  favicon.href := 'res/favicon2.png';
end;
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...