【问题标题】:jquery change browser tab title when click on link in iframe单击 iframe 中的链接时,jquery 更改浏览器选项卡标题
【发布时间】:2014-01-07 20:00:20
【问题描述】:

我有一个包含 2 个 iframe 的索引页面。当我单击 iframe 2 中的链接时,将在 iframe 1 中打开一个页面。现在,当您单击 iframe2 中的该链接时,我想更改浏览器选项卡标题。

我知道如何使用以下脚本更改浏览器标题选项卡,但这仅在索引页面上有效。

<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>

希望你们能帮忙。

【问题讨论】:

    标签: jquery html iframe


    【解决方案1】:

    这应该可行。

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

    首页

    【讨论】:

    • 完美运行,非常感谢! ...像魅力一样工作!
    【解决方案2】:

    完美的马库斯! 我能够在我的 jquery 应用程序中使用您的解决方案,但我在函数中使用了它,因为标题可以根据单选输入中选择的值获得两个值。

    $.fn.relacionamento = function() {
    if ($("input[name=f_exclusivo]:checked").val() == 0) { 
        $('head title', window.parent.document).text('Titulo 01');
    } else { 
        $('head title', window.parent.document).text('Titulo 02');
      }
    };
    $("input[name=f_exclusivo]").click(function(){ $().relacionamento(); });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-19
      相关资源
      最近更新 更多