Forum Moderators: open

Message Too Old, No Replies

Safari won't output with document.write to a new window

Works fine in IE

         

MichaelBluejay

7:42 pm on Apr 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<a href="#" onclick="theWindow=window.open('','name','resizable,height=50,width=200'); theWindow.document.write('test'); return false">link</a>

Clicking the link in Safari pops up the window, but it's empty. IE will correctly populate the window when the link is clicked. What's Safari's problem?

whoisgregg

9:56 pm on Apr 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This works for me in Safari:

<script type="text/javascript">
// <![CDATA[
function PopContent(content){
newWindow = window.open('','newWindow','resizable,height=100,width=200');
var popdoc = newWindow.document;
popdoc.write(content);
popdoc.close();
}
// ]]>
</script>
<a href="#" onclick="PopContent('This is a test'); return false;">link</a>

Added: And in Firefox.

Rambo Tribble

3:02 am on Apr 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can confirm that neither script displays the text in the second window on Konqueror 3.3.2. This suggests it may be a browser version issue. KDE is up to 3.5.2, though 3.3.2 is still the Debian stable release.

whoisgregg

5:49 pm on Apr 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Some more information, the snippet I posted...

Works in:
Safari 2.0.3 (417.9.2)
Firefox/1.5.0.1
Mozilla 1.7.2
Opera 8.0.2

Fails in:
OmniWeb 5.0 (558.46)

All under Mac OS X 10.4.5

rocknbil

8:13 pm on Apr 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it possibly because you're ID'ing your window as name?

Stick with routines as above, those will work with the exceptions mentioned, and use getTime to assign a unique ID to your window.

Rambo Tribble

2:48 am on Apr 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In further testing I have determined that both scripts execute as expected, and successfully write to their windows, in Konqueror 3.4.2.

MichaelBluejay

9:49 pm on Apr 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Okay, what fixed it was adding theWindow.document.close(). Now it works in my Safari Version 2.0.3 (417.8) under OS X 10.4.5. Doesn't work if I omit that. Thanks for the help.