Here is my answer
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></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;
});
});
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';
});
</script>
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?
<script>
window.onblur = function () { document.title = 'A Page?'; }
window.onfocus = function () { document.title = 'New Title'; }
</script>
From your website, you do not have access to an blank page in the browser as there are no script running there.
@empiric I saw a an example about it.
Then please include the example in here and describe why it is not working for you.
@empiric I edit my post.
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