The reason why local_variable failed is because of async Custom HTML Prompt. There is ways to solve this
Put a Pause action after Custom HTML Prompt action (2sec)
Use global variable.
When async is used for Custom HTML prompt, it returns immediately for KM to execute rest of actions, so the macro may finish before the custom prompt get to read the local variable (hence return empty).
This macro is great—I've turned it into a generic subroutine I call from a number of spots. What I'd like to do is add a floating button stuck to the top right corner of the window that would open the URL in the browser.
var button = document.createElement("Button");
button.innerHTML = "My Button";
button.style = "top:10;right:10;position:absolute;z-index: 9999"
For this to work, the data—kmwindowid must be defined in body tag of custom HTML Prompt statically, not dynamically. So your custom prompt need to include the body tag with data—kmwindowid and cannot be created with document.write.
I was using the code above from @macdevign_mac, which uses document.write to put a live webpage into the custom HTML prompt. I'm far from an expert (hence, the help request), but I don't see how I could do that with your template?
Thanks for clarifying. As I want to have an actual web page in the window, I think I can solve this another way—I'll just put my own prompt onscreen in another HTML window, and position the two of them together.
Thank you for this, mrpasini, I can use technique this for my Ultimate Web Search macro. Instead of using Brave and create tabs, I can position six windows on my main screen and another six on my secondary screen:
Toggle this HTML view's visibility based on the Trigger key? e.g. If I press ⌥ + T, it shows up, if I press it again and the view is visible, it closes/hides. Right now, it opens a new web view every time I trigger the macro.
Can I keep the view open in the background, basically in hidden mode, like the ⌘ + H feature of macOS where the app is hidden but still running the background. This would help to load the webview faster the next time I trigger it and take me to the exact place in the view. Reloading it makes some webpages lose their original position