473,503 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Safari Javascript Problem

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 =
window.open('writeme.html','TellAFriend','width=45 0,height=600');
mywondows.document.write("<html>");
mywondows.document.write("<body>");
mywondows.document.write("Working Please Wait........")
mywondows.document.write("<form method='post' name='myform'
action='sendm.php' target='_self'>");
mywondows.document.write("<input type='hidden' name='urlis' value='" +
window.location + "?osadcampaign=tf'>");
mywondows.document.write("<input type='hidden' name='productname'
value ='" + productname +"'>");
mywondows.document.write("</form>");
mywondows.document.write("</body>");
mywondows.document.write("</html>");
mywondows.document.myform.submit();
}

Any one any ideas how i can make this mac compatable...

TA

Oct 17 '06 #1
2 2971
da****@passion8.co.uk said:
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 =
window.open('writeme.html','TellAFriend','width=45 0,height=600');
mywondows.document.write("<html>");
mywondows.document.write("<body>");
mywondows.document.write("Working Please Wait........")
mywondows.document.write("<form method='post' name='myform'
action='sendm.php' target='_self'>");
mywondows.document.write("<input type='hidden' name='urlis' value='" +
window.location + "?osadcampaign=tf'>");
mywondows.document.write("<input type='hidden' name='productname'
value ='" + productname +"'>");
mywondows.document.write("</form>");
mywondows.document.write("</body>");
mywondows.document.write("</html>");
mywondows.document.myform.submit();
}

Any one any ideas how i can make this mac compatable...
I do have an idea. I don't have time to test it, but here you go:

When you dynamically create a document with document.write(), you
should really call document.close() after you're done document.writing
it. The other browsers may guess somehow (maybe because you call a
method of a child of that document) but you can't blame Safari for not
predicting that you won't document.write() anymore.
Acutally, if you document.write() into that window after calling its
document.myform.submit, all the other browsers will likely start the
document from scratch since they closed() it implicitly, while Safari
may be able to append to it. Which behavior is right, the
specifications don't say.
Add this line right after the last document.write in your function:

mywondows.document.close()

and see if it works better in Safari.
--
David Junger

Oct 17 '06 #2
da****@passion8.co.uk wrote:
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.
"...will not work" is not a suitable explanation. Does the new window
open? Does anything get written? Do you see any errors in the script
console?
>
function domywindows() {
//alert('test');
mywondows =
window.open('writeme.html','TellAFriend','width=45 0,height=600');
Since you completely replace the content of the document, why not leave
the URL blank?

window.open('', ...);

mywondows.document.write("<html>");
Instead of a series of document.write statements, use one statement and
concatenate the text to be written:

mywondows.document.write(
"<html><body>Working Please Wait........"
+ "<form method='post' name='myform' "
+ "action='sendm.php' target='_self'>"
+ "<input type='hidden' name='urlis' value='"
+ window.location + "?osadcampaign=tf'>"
+ "<input type='hidden' name='productname' value ='"
+ productname +"'>"
+ "</form></body></html>"
);
mywondows.document.myform.submit();
Before attempting to access elements in the new document, finish
writing it with document.close(), then try to submit the form:

mywondows.document.close();
mywondows.document.myform.submit();

If you don't close the form, Firefox will also continue to look like it
is loading the document until some other event causes it to stop (like
loading another page).

As a general strategy, it seems pointless to create a new (pop up)
window just to submit a form, particularly as many pop-up blockers can
stop you from doing so.
--
Rob

Oct 18 '06 #3

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

Similar topics

4
6000
by: Bernard | last post by:
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...
2
2017
by: Marcia Gulesian | last post by:
The following code suppresses the 'enter' key, when run in I.E. 5.5 or later (Windows) but not when run in Safari (Mac) <body onkeypress="javascript:keysuppress(event)" > function...
3
6668
by: Joe Cox | last post by:
I am having a problem with style properties for dynamic images in Mac OS X Safari. By dymanic images, I mean images allocated with the javascript 'new Image()' call. With static images (created...
7
2515
by: Tom | last post by:
I have an oo-type javascript program running perfectly on IE 6.0+, FF 1.5+, and Opera 7+ on Windows 98+, Linux (RH 9, FC 6), and Mac OS X. 4. As usual, the Safari browser is not working correctly,...
1
3496
by: rynato | last post by:
I ran into an interesting problem while working on a form: I have a drop down list (think <form><select><option>...) of 'open sessions' which a user can choose from to continue entering data....
2
4736
by: Andrew Poulos | last post by:
Testing locally on an Win XP box with the safari pop up blocker disabled: window.close(); will close the window without warning even though the window was not opened by javascript. win =...
15
2628
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...
2
4758
by: rudiedirkx | last post by:
Gents, I have a problem (only in Safari) with the onsubmit in webforms. This topic covers the same subject: http://bytes.com/topic/javascript/answers/166542-onsubmit-safari but not as detailed as...
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7273
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,...
0
7322
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3161
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...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
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 ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
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...

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.