Mendix React Client how to get the current pagename

0
Dojo Client Can be obtained through mx.ui.getContentForm().path method studiopro pagename, but React Client no support getContentForm method. If  use the document.title method, it will be affected by translation, resulting in inaccurate page names
asked
2 answers
2

Hi Su,

I have the following 2 bookmarks that use window.history and the pageName runtime information. Both of them will automatically copy the pagename to your clipboard

 

For getting regular page names you can use:

javascript:(() => {   const name = (window.history.state?.pageName || "").split(".")[1];   if (!name) {     alert("Page name not found.");     return;   }   navigator.clipboard.writeText(name)     .then(() => alert("Copied: " + name))     .catch(() => alert("Failed to copy. Your browser may block clipboard access.")); })();

 

For popup pages you can use:

javascript:(() => {  try {    const entry = performance.getEntriesByType("resource")      .filter(item => item.initiatorType === "script" && item.name.includes("/pages/"))      .at(-1);    if (!entry) {      alert("Popup page not found.");      return;    }    const pageName = entry.name.split("/pages/")[1].split(".")[1];    navigator.clipboard.writeText(pageName)      .then(() => alert("Copied popup: " + pageName))      .catch(() => alert("Found page but could not copy to clipboard."));  } catch (e) {    alert("Error retrieving popup page name.");  }})();

 

Please note that the bookmark for popup pages, opens the last popup page you navigated to. If you would for example have 2 popup pages open at the same time (not a best-practice but it can happen), and you close the last opened one, it will still give you the pagename of that last popup page that your browser navigated to.

 

Hope this helps!

answered
0

Just make a bookmark containing

 

javascript:void(alert(window.history.state?.pageName))

 

react-bookmark.jpg

 

 

It gives a small popup containing the module- and page-name

answered