设置Chrome window.open的页面标题 [英] Setting the page title of Chrome window.open

查看:281
本文介绍了设置Chrome window.open的页面标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些JavaScript用于打开新窗口并显示PDF文件。除了正在打开的新窗口的标题之外,这工作正常。我正在使用window.open函数,并使用document.write函数设置页面的标题(请参阅下面的代码)。该代码适用于FF和IE,但由于某些原因,Chrome浏览器只显示无标题 - 谷歌浏览器。

 < body> 
< a href =javascript:openNewWindow();>点击此处< / a>

< script type =text / javascript>
函数openNewWindow()
{
var pdfWindow = window.open('',window,
'resizable = 1,scrollbars = 0,width = 800,height = 600' );

pdfWindow.document.write('< html>< head>< title> Window Title< / title>< / head>');
$ b pdfWindow.document
.write('< body>< iframe src =id =ifrmname =ifrmwidth =100%height =100 %>< / iframe中>');

pdfWindow.document.write('< / body>< / html>');

pdfWindow.document.close();
}
< / script>
< / body>

注意:我也尝试添加 - pdfWindow.document.title =Title; - 对于JavaScript,没有运气。



有什么具体的事情需要为Chrome或我只是失去了一些东西?


<当我将open()的第一个参数设置为'about:blank'

时解决方案

p>

I have some JavaScript that is being used to open a new window and display a PDF file. This is working fine apart from the title of the new window being open. I am using the window.open function and I have set the title of the page using the document.write function (see code below). The code works fine for FF and IE but for some reason Google Chrome just displays 'Untitled - Google Chrome'

<body>
    <a href="javascript:openNewWindow();">Click Here</a>

    <script type="text/javascript">
        function openNewWindow()
        {
            var pdfWindow = window.open('', "window",
                'resizable=1,scrollbars=0,width=800,height=600');

            pdfWindow.document.write('<html><head><title>Window Title</title></head>');

            pdfWindow.document
                    .write('<body><iframe src="" id="ifrm" name="ifrm" width="100%" height="100%"></iframe>');

            pdfWindow.document.write('</body></html>');

            pdfWindow.document.close();
        }
    </script>
</body>

Note: I have also tried adding - pdfWindow.document.title="Title"; - to the JavaScript, with no luck.

Is there anything specific that is required for Chrome or am I just missing something??

解决方案

Works for me when I set the 1st parameter of open() to 'about:blank'

这篇关于设置Chrome window.open的页面标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆