Привет,
Пытаюсь создать окно в JavaScript и воткнуть в него скрипт. В Mozila работает в IE окно пустое.
<html>
<body>
<input type='button' value='Show/Hide' onclick='javascript:ShowClick();'>
<script type="text/javascript">
function ShowClick()
{
try {
var nwin = window.open("about:blank", "qwerty", "width=500, height=500");
script = nwin.document.createElement('script');
script.type = 'text/javascript';
script.defer = true;
script.text = "document.write('hello');";
nwin.document.getElementsByTagName('head').item(0).appendChild(script);
}
catch (err) {
alert(err.description);
}
}
</script>
</body>
</html>
Здравствуйте, Лекс, Вы писали:
Л>Привет,
Л>Пытаюсь создать окно в JavaScript и воткнуть в него скрипт. В Mozila работает в IE окно пустое.
Do not use the write method or the writeln method on the current document after the document has finished loading unless you first call the open method, which clears the current document window and erases all variables.
поэтому либо сразу писать
var nwin = window.open("about:blank", "qwerty", "width=500, height=500");
nwin.document.write('hello');
либо обойтись без document.write
Здравствуйте, Лекс.
Вместо document.write лучше применять appendChild или insertAdjacentElement.