繁体   English   中英

如何从弹出窗口标题设置浏览器标题

[英]how to set the browser title from popup window title

我正在诗歌网站上工作,我将在弹出窗口中显示诗歌,如何将浏览器标题设置为弹出标题,以使社交媒体共享按钮获取诗歌标题而不是浏览器标题

<div class="popup">
<h2>popup title</h2>
<p>content</p>
<a class="close" href="#close"></a>
</div>
<a href="#x" class="overlay" id="poem4_form"></a>    

尝试这个:

document.title = window.opener.document.title

您可以选择的替代方法:

var win = window.open('', 'foo', '');

//Ensure, the Document is loaded
function check() {        
    if(win.document) {
        //Set Title
        win.document.title = document.title
    } else {
        setTimeout(check, 10);
    }
}    
check();

这基于以下答案: 在窗口弹出窗口中设置标题

这是您的小提琴: http : //jsfiddle.net/QRq2h/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM