WiFiManager icon indicating copy to clipboard operation
WiFiManager copied to clipboard

Custom HTML at the Top of "<body>"

Open ab-tools opened this issue 2 years ago • 3 comments

Added setCustomTopBodyElement allowing to define custom HTML to be added at the top of the "

" tag.

This is very useful to add a custom HTML header, e. g. also a logo at the top of the page.

I know this would in general be possible with WIFI_MANAGER_OVERRIDE_STRINGS and copying the whole wm_strings_en.h file, however, if the only goal is to add a single line of HTML code at the top of the page this seems like a bad idea: Whenever something would get added in that file, these changes would need to be copied over manually to the custom file again.

Having the option to just "inject" and additional HTML code at the top of the body tag (similar as it is already possible to inject something at the bottom of the "head" tag) seems a much better option.

ab-tools avatar Jan 01 '24 15:01 ab-tools

Since you have already done this, may I suggest a change to add a footer as well? (setCustomFooterElement)

I am currently using a hack to add a footer using javascript like this:

wm.setCustomHeadElement("<script>setTimeout(function(){document.querySelector('.wrap').appendChild(document.createTextNode('Build time: " __DATE__ "/" __TIME__ "'));}, 100);</script>");

(I could not use the timestamp from the info page, since it is a timestamp of when the wifi-manager library files were compiled. For repeated builds, old library .o files are reused.)

But having a separate setCustomFooterElement function would be a much simpler approach.

anishsane avatar Aug 21 '24 07:08 anishsane

This is great! I hope you don't mind, I reworked the name as "body header" and added a corresponding "footer" function, PR #1769.

dmadison avatar Oct 23 '24 04:10 dmadison

This should now be closed (superseded by #1769). Thank you!

dmadison avatar Dec 12 '24 22:12 dmadison