473,548 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Safari browser new bug in document.write( )?

Hi,

I am suddenly getting Safari script errors with the following user
agent:

Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML,
like Gecko) Safari/125.8
In a frameset scenario, the framesetting document (top) contains a
function:

function writeDoc(win,tx t){
var doc=w.window.do cument;
doc.open("text/html","replace" );
doc.write(s);
doc.close();
}// function

If a frame contains script such as:

<script>
top.writeDoc(to p.someOtherFram eName,"<body>He llo</body>");
</script>

then Safari requests a URL in the same path of top but that ends with
"/text/html", which of course results in a server error 404, "document
not found".

Files ending with "/text/html" definitely don't exist in that case. It
looks very much like the browser is misinterpreting the
document.open() function.

Obviously the resulting HTTP request is totally bogus - there is not
even code that requests data from the network anywhere near the
function call - the document is written, not loaded.

It should write the frame so that the text "Hello" appears

Has anybody else seen this? I don't have a Mac.

Thanks,

Bernard
Jul 23 '05 #1
4 6008
Bernard wrote:
Hi,

I am suddenly getting Safari script errors with the following user
agent:

Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML,
like Gecko) Safari/125.8

Could be considered a bug, but Safari is very picky about
"document.write ()":

<head>
<script type="text/JavaScript">
document.write( "Hello")
</script>
</head>

Creates an error(or doesn't work)

but
<body>
<script type="text/JavaScript">
document.write( "Hello")
</script>
</body>
works as expected.
Mick.

Jul 23 '05 #2
Mick White wrote:
<snip>
Could be considered a bug, but Safari is very picky about
"document.write ()":
Are you sure it is not HTML that it is being picky about?
<head>
<script type="text/JavaScript">
document.write( "Hello")
</script>
</head>

Creates an error(or doesn't work)
The HEAD element has very restricted content, not including text as a
child of HEAD. In principle encountering the text output from -
document.write - in that context should terminate the HEAD and imply the
opening of the BODY (in HTML, but not XHTML), but maybe Safari cannot
cope with doing that when using - document.write.
but
<body>
<script type="text/JavaScript">
document.write( "Hello")
</script>
</body>
works as expected.


Whiting text into the BODY is much more normal behaivure.

Richard.
Jul 23 '05 #3
Bernard wrote:
<snip>
function writeDoc(win,tx t){
The parameters - win - and - txt - are never employed in this function.
var doc=w.window.do cument;
If - w - is not a defined global variable (probably referring to a
window object) then this line will error.
doc.open("text/html","replace" );
doc.write(s);
The variable - s - is not defined in this function.
doc.close();
}// function

If a frame contains script such as:

<script>
top.writeDoc(to p.someOtherFram eName,"<body>He llo</body>");
Assuming that named (or IDed) frames will be available as named
properties of window objects is not reliable.
top.frames.some OtherFrameName - will work on more browsers, (relative
references through the - parent - property instead of absolute
references through - top - would make the system more reliable in
various presentation context. i.e. with your frameset displayed in
another (though that is not always desirable)).
</script>

then Safari requests a URL in the same path of top but that
ends with "/text/html", which of course results in a server
error 404, "document not found". Files ending with "/text/html" definitely don't exist in that
case. It looks very much like the browser is misinterpreting the
document.open() function.
It looks like it may be calling a window.open function instead of a
document.open function, as the first parameter appears to be being taken
as a URL. It is difficult to say because the code you have provided will
error before it does what you describe and so is probably not the code
that exhibits the problem you are describing (either it is incomplete or
has been mangled in transcription).

<snip> It should write the frame so that the text "Hello" appears

<snip>

That is not what the code above should be expected to do.

Richard.
Jul 23 '05 #4
Hi Mick,

Thanks for your reply.

First my function had errors, it should be:

function writeDoc(win,tx t){
var doc=win.window. document;
doc.open("text/html","replace" );
doc.write(txt);
doc.close();
}// function
Its purpose is to write the content of an entire frame. Therefore the
need for the calls doc.open("text/html","replace" ); and doc.close();.

Thanks for your bug description. I didn't know of such a bug in
Safari.

In this context, however, it should not be sensitive to the bug that
you describe.

It looks rather like Safari is mixing up two different objects:
document and window.

It could be that if I call from a frame

top.writeDoc(to p.someOtherFram eName,"<body>He llo</body>");

then Safari fails in such a way that win.window.docu ment returns a
window instead of a document as expected.

Could you or some other nice person shed any light on this with the
following browser?

"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2
(KHTML, like Gecko) Safari/125.8"

Unfortunately I don't have a Mac and the only errors I am getting are
the 404 entries in the log files. Other Safari versions seem to be ok.

I am thinking of a testcase such as this:

<HTML>
<HEAD>
<TITLE>Safari document test</TITLE>
<SCRIPT>
function writeIt(){
writeDoc(frame1 ,"<body>Hell o</body>");
}

function writeDoc(win,tx t){
var doc=win.window. document;
doc.open("text/html","replace" );
doc.write(txt);
doc.close();
}

</SCRIPT>
</HEAD>
<FRAMESET rows="50%,50%" onLoad=writeIt( )>
<FRAME src="javascript :'<BODY bgcolor=black>' " name=frame1>
<FRAME src="javascript :'<BODY bgcolor=black>' " name=frame2>
</FRAMESET>
</HTML>

Regards,

Bernard

Mick White <mw******@BOGUS rochester.rr.co m> wrote:
Bernard wrote:
Hi,

I am suddenly getting Safari script errors with the following user
agent:

Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/125.2 (KHTML,
like Gecko) Safari/125.8

Could be considered a bug, but Safari is very picky about
"document.writ e()":

<head>
<script type="text/JavaScript">
document.write( "Hello")
</script>
</head>

Creates an error(or doesn't work)

but
<body>
<script type="text/JavaScript">
document.write( "Hello")
</script>
</body>
works as expected.
Mick.


Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2090
by: Kim Forbes | last post by:
Hi, I realize my first problem is that I'm using browser detection and not feature detection. Maybe someone can help me understand feature detection. This script works in every browser that I need it too, except Safari 1.0.2 Here is the script. Please tell me if there is any more information I can give you.
5
5189
by: joaopedrogoncalves | last post by:
Hi, I want to load an external javascript file, get its results and stick them inside a <div> block. I also want to do this in several places on a web page. This way the browser doesn't have to wait for the external resource to load to show up the page, thus giving a perceiving faster load time for the user.
2
2500
by: drew197 | last post by:
I am a newbie. This is someone else's code which I have to modify to work in Mozilla and Safari. The changes I made so far have allowed it to work in Mozilla but not Safari. It seems to be getting hung up on the first line of code. I put an alert after that line and I never saw it in Safari but I did see it in Mozilla. Any Thoughts? ...
4
5604
by: drew197 | last post by:
I am a newbie. I am editing someone elses code to make it compatible with Firefox and Safari. In IE, when you click on the proper link, a block of text is shown in a nice paragraph form. But, in FireFox and Safari it appears as a narrow column of text with only 2-3 words per line. Here is the code: function showAll()
34
3804
by: Simon Wigzell | last post by:
document...focus() will scroll the form to move the specified text field into view on everything I have tried it with except Safari on the MAC. The form doesn't move. Any work around? Thanks.
2
2977
by: darren | last post by:
I have a small Javascript problem with that mutch love web browser safari, I tested the code on all other browsers PC (Win) and Linux and IE on the mac and it seams to work ok, but for some reason it will not work with safari. function domywindows() { //alert('test'); mywondows =...
2
2104
by: justplain.kzn | last post by:
Hi, I have a table with dynamic html that contains drop down select lists and readonly text boxes. Dynamic calculations are done on change of a value in one of the drop down select lists. Using Safari,my first iteration the script works fine ( indicating that there are 33 form variables ). When trying another dropdown select value, the
5
2677
by: loveshack | last post by:
Can anyone help me please (i am quite a novice, but having fun learning). Im not sure if this is an ASP problem, a javascript problem or a browser problem. Firstly, everything i have written works fine in IE7 and beta IE8. My pages do not work however in Safari or Firefox, and please dont beat me, but i use Frontpage to write my site, and i...
15
2639
by: GinnTech | last post by:
I have a site that works perfectly in IE6 IE7 FF2 FF3 but not in the latest Safari. Here is the issue. I am attempting to call functions within a flash object. When trying to attempt to retrieve the object to call the functions IE6 IE7 FF2 FF3 all return Objects to work with. In Safari a function is returned. Here is the code. /
0
7438
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7466
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3475
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.