Solution 1 :

Here is my answer

<script src=""></script>

$(function () {
    var message = "New Title!";
    var original;

    $(window).focus(function() {
      if(original) {
        document.title = original;
    }).blur(function() {
      var title = $('title').text();
      if(title != message) {
        original = title;
      document.title = message;

Problem :

I have a problem about changing website title during two process.

When I enter webpage, its title has changed via the code shown below.

<script type="text/javascript">

    $(document).ready(function() {
        document.title = 'New Title';


The sceranio,

  • There are two blank page in my browser. a.html and b.html
  • My website is a.html and its title “A page”
  • When I enter to the a.html, its name changed as New title
  • When I click to the b.html page, I want to change title of a.html as “A Page”

When I am at the any blank page in browser, I want to change its title again. How can I do it?

I found a code snippet about it . Is it right?


window.onblur = function () { document.title = 'A Page?'; }

window.onfocus = function () { document.title = 'New Title'; }


Comment posted by empiric

From your website, you do not have access to an blank page in the browser as there are no script running there.

Comment posted by S.N

@empiric I saw a an example about it.

Comment posted by empiric

Then please include the example in here and describe why it is not working for you.

Comment posted by S.N

@empiric I edit my post.

Comment posted by question

Ah understood now, I thought with blank page you mean a new tab in your browser, but you have access to both pages.So you would need to detect when you are not on the page or rather when you are leaving a page and trigger the title chang. This