Setting the title of the Chrome window.open page

I have JavaScript that is used to open a new window and display a PDF file. This works great, except that the name of the new window is open. I use the window.open function and I set the page title 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 also tried adding - pdfWindow.document.title = "Title"; - in JavaScript, with no luck.

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

+8
javascript google-chrome
Feb 14 2018-11-11T00:
source share
2 answers

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

+8
Feb 14 '11 at 15:48
source share

You need to specify the URL in the first parameter, for example "about: blank":

 window.open('about:blank', "window", 'resizable=1,scrollbars=0,width=800,height=600'); 
+4
Feb 14 '11 at 15:55
source share



All Articles