Web server - hash urls aren't working

What sort of webserver does BTT use to serve on localhost? (Apache, nginx, etx?)

I'm using the webserver to display a cool html cheatsheet thingy on a floating menu. I use the link http://localhost:1234///cheaters-master/cheaters/index_local.html and it works great. But it would be even better to use hash links like

http://localhost:1234///cheaters-master/cheaters/index_local.html#freeform

Note the :hash:
and have it load specific pages in the same window without me making multiple menus with a different link.

Apache or nginx would be way overkill :wink: It's a super simple embedded webserver. I'll check whether I can add support for hash urls there.

For now it would be easy to get this working with Java Script and URL parameters instead (e.g. http://localhost:1234///cheaters-master/cheaters/index_local.html?scrollTo=freeForm )

Something like this should work:

<!DOCTYPE html>
<html lang="en">
<head>
   <script>
   document.addEventListener("DOMContentLoaded", function() {
    // Function to get the value of a specific query parameter
    function getQueryParam(param) {
        const urlParams = new URLSearchParams(window.location.search);
        return urlParams.get(param);
    }

    // Get the scrollTo parameter from the URL
    const scrollToId = getQueryParam('scrollTo');

    // Check if scrollToId has a value and the element exists
    if (scrollToId) {
        const elementToScroll = document.getElementById(scrollToId);
        if (elementToScroll) {
            // Scroll to the element
            elementToScroll.scrollIntoView({ behavior: 'smooth' });
        } else {
            console.warn('Element with ID:', scrollToId, 'not found.');
        }
    } else {
        console.warn('No scrollTo parameter found in the URL.');
    }
});
   </script>

</head>
<body>

   <div id="test1" style="width:200px;height:200px;">1</div>
   <div id="test2" style="width:200px;height:200px;">2</div>
   <div id="test3" style="width:200px;height:200px;">3</div>
   <div id="test4" style="width:200px;height:200px;">4</div>
   <div id="test5" style="width:200px;height:200px;">5</div>
   <div id="test6" style="width:200px;height:200px;">6</div>
   <div id="test7" style="width:200px;height:200px;">7</div>
   <div id="test8" style="width:200px;height:200px;">8</div>

</body>
</html>

Hey Andreas. Do you think you will provide a patch for this in the upcoming future ? I can’t read Java script. It would be very cumbersome trying to get it to work with your workaround. Is there a reason it hash-url’s don’t work? I can forward your response to the developer who wrote the original HTML cheat sheet who has shown interest in fixing it. (Brett Terpstra). Cheers

I have two machines and the server doesn’t work for my floating window on my computer at work. It has a wired connection. And it has web-filtering software installed called Netskope. It acts like a vpn but is more like a firewall which I can’t disable. It appears under vpn in system settings. I know the BTT server works because I can type I. The local host url into any browser and my content appears. The IT department says the software doesn’t block local host and doesn’t interfere with the port (I’ve used 12345), is this something I should experiment with in BTT IP settings for the web server, or should I use system settings to try and bypass the web server IP in proxy configuration ?

At home, using the default IP and a random port, it works fine.

how are you trying to access it? From the same machine BTT is running on or from some other machine?

Unfortunately I don't know that Netskope software and can't really tell, with firewalls like Little Snitch BTT's webserver works fine. If that software acts as a VPN for all apps it might not be possible to get around this :-/

I don’t think it’s Netskope software because my web-view content appears in a browser window. There’s also proxy configuration files in system settings. I’m wondering if it could be a conflict there. Would changing the IP in BTT help? I’m accessing it on the same computer. Also, if I bring the work computer home I can get the web-view to show the content! Do these further details jog your mind in what could be causing problems?

I’ve fixed it by changing localhost in the url to the IP for better touch tool 127.0.0.1. Does that sound abnormal ?

This solution will do for now. I’m not sure what will happen when I take the computer to my home network :grimacing:.

Thanks for your help.

yes that makes sense, it should also be the default in BTT. Maybe you had some reason to change that to localhost previously?

The documentation says use localhost for local files and the default IP for other devices. I’ve never needed to use url’s with an IP address as my floating menus are all local, custom designed cheatsheets :slight_smile:

Is the correct setup for local files to use the IP address? As I said earlier my personal computer works and the work computer works on my home network using localhost. I’d love to know what could possibly conflict at work.

ah sorry, I should update the docs on this, with localhost 127.0.0.1 is meant (which is localhost). Probably the network filter tool prevents localhost from being resolved to 127.0.0.1.

1 Like

Any news on support for hash urls?

Same or similar error in Web View / HTML Items. Addresses with hash reference in URL do not load in Floating Menus.

  • "BTTMenuItemText" : "https:\/\/ffmpeg.org\/ffmpeg-all.html",
  • "BTTMenuItemText" : "https:\/\/ffmpeg.org\/ffmpeg-all.html#Generic-options",

Resolved - See Bug Report:
https://community.folivora.ai/t/url-not-working-in-show-floating-webview/10331/5