How to Change Browser Title Dynamically (v2021)

If you want to change the browser’s title dynamically by using the current page title, then this trick is for you. Simply set a client variable by using Page_Rendering server event, after that display it by using Client Script that belongs to all pages.For example, when we are visiting Sales by Category for 1997 page from PHPMaker Demo Project (for example), then the browser title will be changed to: Sales by Category for 1997 < PHPMaker Demo Project. That means, the format of browser title is: {PageTitle} < {BodyTitle}

  1. Put the following PHP code into Page_Rendering server event under Server Events → Global → All Pages:
// set a client variable named Browser_Title by PageTitle and BodyTitle (project name)
SetClientVar("Browser_Title", Language()->phrase(CurrentPage()->TableName) . " < " . Language()->projectPhrase("BodyTitle"));
  1. Put the following Javascript code into Client Script under Client Scripts → Global → Pages with header/footer:
var Browser_Title = ew.vars.Browser_Title;
document.title = Browser_Title;
  1. Make sure you have already re-generated ALL the script files.
  2. Done.

Great, thanx!For multi-language can be as:

SetClientVar("Browser_Title", Language()->TablePhrase(CurrentPage()->TableName, "TblCaption") . " < " . Language()->projectPhrase("BodyTitle"));

Great, amazing - I managed to implement it on a record view. For example if open a record for a car BMW 5 Series - wanted to show the title of the car on the browser.Table Specific>>View Page>>Page_DateRenderingSetClientVar(“Browser_Title”, $this->CarTitle->ViewValue." >> ".Language()->projectPhrase(“BodyTitle”));Amazing, wanted the feature so much

Thanks for sharing this idea. It really helps! Especially when a user long click the arrows back and forth, the dynamic titles are like spotlights.