I create an empty popup window to which I write html code, including a title tag. This has worked before on all browsers, but Safari 5 or 6 do not work.
The code (minimized example code):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Main Window Title</title>
</head>
<body>
<p>The main page opens a second window:</p>
<SCRIPT language="JavaScript" type="text/javascript">
myWindow = window.open();
myWindow.focus();
myWindow.document.write("<html><head><title>The Other Window Title<\/title><\/head><body><p>Some text<\/p><\/body><\/html>");
myWindow.document.close();
</SCRIPT>
</body>
</html>
In Firefox this results in a main page titled “Main Window Title” and a second window titled “The Other Window Title”.
But in Safari, the second window’s title remains the generic “Untitled”.
To me, the Safari behavior appears to be a bug, but I wonder if there is a way to make it work anyway?
(If I supply an url parameter to the window.open, where the url is a web page with a title tag, then it displays correctly, but I do of course not want that since I want it to be dynamically created.
I also tried inserting myWindow.document.title = "A new title"; but it did not have any effect in Safari, (but it has in Firefox).)
Make the url
about:blankExample: