jquery change browser tab title when click on link in iframe

html, iframe, jquery

Solution

This should work.

<script type="text/javascript">
$(document).ready(function(){
    $('#link1').click(function(){
        $('head title', window.parent.document).text('HelloWorld');
    });
});
</script>

Home

Problem

I have a index page with 2 iframes in it. when I click on a link in iframe 2 a page will be opened in iframe 1. Now as an extra I would like to change the browser tab title when you click on that link in iframe2. I know how to change the browser title tab with the following script but that does only work when it is on the index page. ``` <script type="text/javascript"> $(document).ready(function(){ $('#link1').click(function(){ $('head title').text('HelloWorld'); }); }); </script> <a id="link1" href="home.html" target="iframe1">Home</a> ``` Hope you guys can help.

Original source