url in webview item showing code

I have a floating menu that contains a Webview/HTML Item. I've added, in the Webview config, a localfile:// url but rather than seeing the rendered html I'm seeing just the HTML code. What am I missing?


sounds like your file is in the wrong format. Maybe it was accidentally saved as rich text document? (I just tried here to make sure the localfile scheme still works fine)

What happens if you open that file in Safari?

It renders correctly. The file type is HTML text, default app is Firefox. I've just created a new html file in VS Code and it does the same thing. Doublr clicking no the file opens and renders it in FIrefox.

Code:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>My Website</title>
    <link rel="stylesheet" href="./style.css">
    <link rel="icon" href="./favicon.ico" type="image/x-icon">
  </head>
  <body>
    <main>
        <h1>Welcome to My Website</h1>  
    </main>
	<script src="index.js"></script>
  </body>
</html>

Strange, which macOS version are you on?

yeah, it does seem odd.

I'm on 14.5

https://www.bbc.co.uk works. FWIW

I really have no idea, the code for this is really simple as it's just using the standard macOS webview.

Could you try to right-click the webview and choose "inspect", then create a screenshot of the inspector view?


If I place the html file in the preset folder and use presetfile://Info.html, it works just fine.

seems to be getting wrapped:

Must be some Safari/macOS security feature as BTT never wraps anything. However I have no idea what triggers it. It seems to work from any folder here :neutral_face:

presetfile:// does exactly the same as localfile:// (after resolving the path)

Maybe it's somehow related to Safari not being the default browser. In your screenshot it also shows some added styles from "User Agent Style Sheet".
Maybe try setting the useragent in the webview config manually to:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15

Changing the user agent didn't work but obviously it's something out of kilter at my end. I'll dig deeper and post if I find anything. In the meantime I can keep the html in the preset folder.

Thanks for your time, Andreas.