Change Browser Tab Name Title on Edit with Javascript

Tips submitted by ASP.NET Maker users
Post Reply
xgis
User
Posts: 68

Change Browser Tab Name Title on Edit with Javascript

Post by xgis »

Below is simple Javascript code to change the Browser Tab Title based on the active edit or view record.
This is useful when editing in multiple tabs where multiple row records are being updated separately.
In our case we are opening the Database Editing Application from a separate .Net Application button click event
In this case the user may right click 'Duplicate Tab' and edit or view each record separately.

This method uses 3 Client Script code locations within ANM to custom name the Tab.
Firstly the Title within the ANM project under 'HTML | General | Title' field is left blank.
This value is then populated after generation from;

//Client Scripts | Global | Pages with Header Footer | Global Code
//eg document.title='Database Edit App';
//This one will show in List and Other Views and will be the Default Title for your App

// Use the code below to show a custom Edit Page Browser Tab Name
// Client Scripts | Table Specific | Edit Page | Startup Script
// The prefix "Edit " below is used to let the user know the page type and is not needed if you just need to see the field name value.

if (document.title !== document.getElementById("x_FieldName").value)
{
document.title="Edit " + document.getElementById("x_FieldName").value;
}
else
{
document.title='Database Edit';
}

//Use this code to show a custom View Page Browser Tab Name
// Client Scripts | Table Specific | View Page | Startup Script
// This method is different from Edit as it needs to access the 'innerText' because there is no 'field' value.

if (document.title !== document.getElementById("el_FieldName").innerText)
{
document.title="View " + document.getElementById("el_FieldName").innerText;
}
else
{
document.title='Database View';
}


Post Reply