Set the title of angular application from the parent tab in chrome

Published

I have an application which opens another angular application in a new tab on clicking a button. I need to override the title of the new tab from the parent tab and set a value. Some mock code below

<!DOCTYPE html>
<html>

<head>
    <title>New tab</title>
</head>

<body>
    <div>
        <input id="toolId" placeholder="ToolId" style="padding: 4px 0; width: 70px;" />

        <button id="button">Launch</button>
    </div>

    <script>
        window.onload = function () {
            document.getElementById('button').addEventListener('click', () => {

                var newWin = window.open('http://localhost:4200', "_blank");

                // add a load listener to the window so that the title gets changed on page load
                newWin.onload = function() {
                    newWin.document.title = 'New Title';
                    console.log('Loaded');
                };

                // newWin.document.title = 'New Title';
                
            })
        }
    </script>
</body>

</html>

But when i try to do this , i always see the default value set by the angular application rather than what is set by the above code. What am i missing here ? Is it blocked by chrome by chance, could not find any relavent doc if it is .

Source: Angular Questions

Published
Categorized as angular, javascript, tabs Tagged , ,

Answers

you can check this documentation
Link


Verda Schaden

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq