top.document.write() on Safari

  • andrushok
  • Novice
  • Novice
  • User avatar
  • Posts: 24

Post 3+ Months Ago

Hi All
I just met the problem on Safari (only on Safari, other browsers are fine).

The simple js code
Code: [ Select ]
function ToTop()
{
  bd = "some tags ...";
  top.document.write( bd);
}
....
<body onLoad="ToTop()">
....
  1. function ToTop()
  2. {
  3.   bd = "some tags ...";
  4.   top.document.write( bd);
  5. }
  6. ....
  7. <body onLoad="ToTop()">
  8. ....


If the window is a top window all works fine. If it is a frame inside the top window - Safari crashes and Mac asks to report the bug. Have you met something similar that?
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Nope... but I can't say I'm surprised.
All the more reason to let Macs go the way of Tandy...
.c
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

Maybe I missed something in your post...but it sounds like Safari is having trouble differenciating the parent/child relationships....

you might try a browser sniffer...then once you isolate safari...try parent.top.blah blah blah

PS: I agree w/ Carnix...MAC's should just fade into oblivion...if it weren't for people trying to be non-comformist it would already be dead...in my opinion they're just inferior
  • andrushok
  • Novice
  • Novice
  • User avatar
  • Posts: 24

Post 3+ Months Ago

I have found the workaround

Code: [ Select ]
<!--- Top Window --->
....
<body>
<div id="div_in_body" style="width:auto; height:auto;">
....
</div>
</body>

<!--- Frame Window --->
function ToTop ()
{
  bd = "some tags ...";
  top.document.getElementById('div_in_body').innerHTML = bd;
}
....
<body onLoad="ToTop()">
  1. <!--- Top Window --->
  2. ....
  3. <body>
  4. <div id="div_in_body" style="width:auto; height:auto;">
  5. ....
  6. </div>
  7. </body>
  8. <!--- Frame Window --->
  9. function ToTop ()
  10. {
  11.   bd = "some tags ...";
  12.   top.document.getElementById('div_in_body').innerHTML = bd;
  13. }
  14. ....
  15. <body onLoad="ToTop()">


It works (I hope) on all browsers. I tested it on Safari. Any other attempt to change BODY on TOP crashes Safary. I tryed even

Code: [ Select ]
<!--- Top Window --->
....
<body id="top_body">
....
</body>

<!--- Frame Window --->
function ToTop ()
{
  bd = "some tags ...";
  top.document.getElementById('top_body').innerHTML = bd;
}
....
<body onLoad="ToTop()">
  1. <!--- Top Window --->
  2. ....
  3. <body id="top_body">
  4. ....
  5. </body>
  6. <!--- Frame Window --->
  7. function ToTop ()
  8. {
  9.   bd = "some tags ...";
  10.   top.document.getElementById('top_body').innerHTML = bd;
  11. }
  12. ....
  13. <body onLoad="ToTop()">


It does not work. Any references to top.document.body via parent do not work too.

I hate Safari and IE on Mac :evil:

To s15199d. What does means "PKA" on your avarat? :?
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Pi Kappa Alpha


It's a Fraternity:
http://www.pka.com/

Cached Google Version... the site came up broken when I tried it.... typical pikes. heh (just kidding!) :P

http://66.102.7.104/search?q=cache:h65l ... lpha&hl=en


.c


*EDIT: looksl like the site is actually http://www.pikes.org/ go figure...
  • s15199d
  • Expert
  • Expert
  • User avatar
  • Posts: 524
  • Loc: NC, USA

Post 3+ Months Ago

Yes Carnix I'm a greek man. I appreciate however your propensity to withhold what I'm sure is a miriad of greek epithats.
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

heh, naw. I am too =] (Figi)
Although, I really wasn't very involved... after the annoying first year, I got an apartment and that was pretty much that. Mostly I was in a frat for family reasons. I doubt I would have gone that route otherwise, but it wasn't that bad. Membership has it's privilages =]

.c
  • andrushok
  • Novice
  • Novice
  • User avatar
  • Posts: 24

Post 3+ Months Ago

Oh, guys. It is wonderfull discussion here! :)
However I am about our "sheeps"...
Unfortunatelly the code I wrote above does not work on Safari in some cases. So there is a new workable version
Code: [ Select ]
<!--- Top Window --->
....
<body>
<div id="topbody">
....
</div>
<div id="errbody" style="visibility:hidden; width:0px; height:0px;">&nbsp;</div>
</body>

<!--- Frame Window --->
function ToTop ()
{
  bd = "some tags ...";
  var db = top.document.getElementById('topbody');
  var derr = top.document.getElementById('errbody');

  db.style.visibility = "hidden";
  db.style.width = "0px";
  db.style.height = "0px";

  derr.style.visibility = "visible";
  derr.style.width = "auto";
  derr.style.height = "auto";
  derr.innerHTML = bd;
}
....
<body onLoad="ToTop()">
  1. <!--- Top Window --->
  2. ....
  3. <body>
  4. <div id="topbody">
  5. ....
  6. </div>
  7. <div id="errbody" style="visibility:hidden; width:0px; height:0px;">&nbsp;</div>
  8. </body>
  9. <!--- Frame Window --->
  10. function ToTop ()
  11. {
  12.   bd = "some tags ...";
  13.   var db = top.document.getElementById('topbody');
  14.   var derr = top.document.getElementById('errbody');
  15.   db.style.visibility = "hidden";
  16.   db.style.width = "0px";
  17.   db.style.height = "0px";
  18.   derr.style.visibility = "visible";
  19.   derr.style.width = "auto";
  20.   derr.style.height = "auto";
  21.   derr.innerHTML = bd;
  22. }
  23. ....
  24. <body onLoad="ToTop()">


Some comments: Safari crashes, when I try to override somthing in top.document.body. Maybe it depends on my content inside <div id="topbody">. I do not know.

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 77 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.