How to Load Another Webpage in the Custom HTML Prompt?


Does anyone know how to load another page, e.g., or, in the Custom HTML Prompt?

I tried <iframe>, it will simply open the page in the default web browser instead of loading the page in the HTML Prompt window.

<meta charset=utf-8 />
<iframe src="" name="targetframe" allowTransparency="true" scrolling="no" frameborder="0" >

I saw this on the Wiki page. It may have explained why the webpage is opened in the default web browser. But I have no idea what data-kmhandleschemes is or how to implement it or if it is related to my issue at all.

Handling HTTP links

By default, http: and other links (everything except file: links) are passed to the to open as normal.

You can elect (v8+) to handle schemes yourself by including a data-kmhandleschemes attribute in the body element, or by implementing the KMHandleSchemes() function.

Either can return the schemes you want to handle (most likely only http) as a comma or space separated list.

An HTML iframe is used to display a web page within a web page. Here's an explanation and demo:

I've barely used CSS myself, so I've never used this mechanism.

I'm using it in my sample code above, but as I said,

Ok, sorry. You've described the problem then. I'll google some examples, and if I find any, I'll add them here.

1 Like

I don't know any way to do this with a live web page (i.e. one where the Javascript, user input, etc. will all still work), but I had to solve this for a static page, and here's what I did:

Execute Shell Script: curl -s -o /tmp/thefile.html https://thedomain.blah.etc/path
Display Custom HTML Prompt from file: /tmp/thefile.html

Works great for my needs, but probably won't work for what you want.


The following will load the website into Custom Html Prompt window.

    <meta charset=utf-8/>
<body data-kmhandleschemes="http https"
      data-kmwindow="SCREEN(Main,Left,35%),SCREEN(Main,Top,17%),900,800" style="width: 100%;">


    "use strict;";

    function KMHandleSchemes() { // either use this function to return schemes or in data attribute
        return "http https";

    function KMInit() {
        window.location.href = "";


Works perfectly!
Thank you very much!

Excellent, that greatly simplifies my window work as well—thanks!


Beautiful, @macdevign_mac! Here's a variant that, if there's selected text in any app, feeds that to Google. I'm often working in InDesign or BBEdit and reluctant to launch a browser just to reference something online. This takes care of that.

It should properly use a local variable for the search string but I haven't been able to figure out how to pass a local to a JS function. As an alternative, I use a global variable that is treated a bit like a local (reusable by anything). And the storage overhead isn't much anyway.

Browser-free Google Search Macro (v10.0.2)

Browser-free Google Search.kmmacros (6.4 KB)


I had the same purpose.
The HTML Prompt is light and launches much faster.
Another advantage of the HTML Prompt is that the window floats on the top. It's useful when we want to refer to something online as we work on other apps.


Hi @mrpasini I like this a lot. Could you give a hint how it could be adapted to feed the selected text into Google Translate rather than Google Search?

I am assuming the initial text before =%CurrentClipboard% in this Action would be the key?


This scheme works really well to create stand-alone Web apps, too. I have a few PHP/MySQL apps (spiced with Spry AJAX and JavaScript) that I can now run in their own window from a hot key. No need for Platypus or other wrappers.

I just expanded this version to show a popuplist of them with Google as an option, too, if there's no selection and pass that URL to the HTML Prompt. But you could easily just create a macro for each Web app you have with its own hot key, of course.

1 Like

Sure, the Translate option for Text Tools I has the code. Let me conjure up a quick version...


Translating the above text:

Ho appena ampliato questa versione per mostrarne un elenco popup con Google come opzione, se non c'è selezione e passare quell'URL al prompt HTML. Ma potresti facilmente creare una macro per ogni app Web che hai con il suo tasto di scelta rapida, ovviamente.

I get a warning to choose an application that can open about:blank that I didn't resolve but here's a preliminary version that flies well enough:

Browser-free Google Translate Macro (v10.0.2)

Browser-free Google Translate.kmmacros (7.5 KB)

1 Like

Thanks @mrpasini

Yes, I get that too. I wonder why.

This is the Macro I made for myself before, which works well but relies on Safari to open Google Translate. That's why I wondered if the code could be modified to work in your Browser Free version:

Google Translate.kmmacros (34.1 KB)
Google Translate

OK, this takes care of that. It's a little app that handles the request to about:blank. The author explains:

Browsers are supposed to display the URL about:blank as a blank page. Unfortunately, some web browsers or similar apps do not know how to do this and will ask macOS to handle this URL. Apps that do this are misbehaving, but until these apps are fixed, you can use AboutWeb to silence these errors.


My solution works but it lost all KM functions of custom Prompt as window.KeyboardMaestro no longer available.

I wonder if Peter can find a way to add window.KeyboardMaestro into custom prompt when using site url. That will be good idea. I don't think security is the worry because there is other library doing that exactly,

  • JxBrowser (Java)
  • Microsoft WebView2 (.net)
  • Microsoft PlayWright (node.js library)
  • Tampermonkey (Browser extension)
    and many more.

Imagine able to access the power of KM in a site.

By the way, you can also inject custom javascript this way by assigning a name to data-kmwindowid in the body tag. [action:Custom HTML Prompt [Keyboard Maestro Wiki]] and making custom prompt asynchronous


Some may suggest using iFrame inside custom prompt but it does not work if you are trying to inject code into iframe due to WKWebview's security check.


This that you provided is a must for those who using site in Custom HTML Prompt window. Even Google Translate site will popup the annoying following message


So the solution you provide did suppress that perfectly.

@mrpasini, thanks so much for sharing. I'll be using this one daily! (Another fine example of the amazing versatility of Keyboard Maestro.)

BTW, with KM 8.0.3+ it seems that a local variable should work, but for some reason with this macro it doesn't. (I confirmed on my system: macOS 12.1; KM 10.0.2.) @peternlewis, what are we missing?

You will just have to preserve the window.KeyboardMaestro object if you wish to replace the window object. I am no JavaScript expert, but I presume you can take a reference to the object and it will remain after the window is deleted.


I have verified that window.KeyboardMaestro object does exists. I find that in order to inject js code into custom prompt that use site (eg, the injected code should be done in the "Execute Javascript in Custom Prompt" action (orange) where window.KeyboardMaestro exists.

window.KeyboardMaestro only exists in "Custom Floating HTML Prompt" action (purple) before the line window.location.href = url is called, and custom functions defined there are no longer recognized once the location is loaded.

So in other words, it is possible to inject js code for Custom Prompt Window that use site.

For example, I have removed unwanted elements in Google Translate site in Custom Prompt Window and variable passing is done through window.KeyboardMaestro's GetVariable function