473,602 Members | 2,764 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('wr iteme.html','Te llAFriend','wid th=450,height=6 00');
mywondows.docum ent.write("<htm l>");
mywondows.docum ent.write("<bod y>");
mywondows.docum ent.write("Work ing Please Wait........")
mywondows.docum ent.write("<for m method='post' name='myform'
action='sendm.p hp' target='_self'> ");
mywondows.docum ent.write("<inp ut type='hidden' name='urlis' value='" +
window.location + "?osadcampaign= tf'>");
mywondows.docum ent.write("<inp ut type='hidden' name='productna me'
value ='" + productname +"'>");
mywondows.docum ent.write("</form>");
mywondows.docum ent.write("</body>");
mywondows.docum ent.write("</html>");
mywondows.docum ent.myform.subm it();
}

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

TA

Oct 17 '06 #1
2 2984
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('wr iteme.html','Te llAFriend','wid th=450,height=6 00');
mywondows.docum ent.write("<htm l>");
mywondows.docum ent.write("<bod y>");
mywondows.docum ent.write("Work ing Please Wait........")
mywondows.docum ent.write("<for m method='post' name='myform'
action='sendm.p hp' target='_self'> ");
mywondows.docum ent.write("<inp ut type='hidden' name='urlis' value='" +
window.location + "?osadcampaign= tf'>");
mywondows.docum ent.write("<inp ut type='hidden' name='productna me'
value ='" + productname +"'>");
mywondows.docum ent.write("</form>");
mywondows.docum ent.write("</body>");
mywondows.docum ent.write("</html>");
mywondows.docum ent.myform.subm it();
}

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.writin g
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.docum ent.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('wr iteme.html','Te llAFriend','wid th=450,height=6 00');
Since you completely replace the content of the document, why not leave
the URL blank?

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

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

mywondows.docum ent.write(
"<html><body>Wo rking 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='productna me' value ='"
+ productname +"'>"
+ "</form></body></html>"
);
mywondows.docum ent.myform.subm it();
Before attempting to access elements in the new document, finish
writing it with document.close( ), then try to submit the form:

mywondows.docum ent.close();
mywondows.docum ent.myform.subm it();

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
6010
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 frameset scenario, the framesetting document (top) contains a
2
2023
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 keysuppress(e) { if (e.type=="keypress" && e.keyCode=="13") { event.returnValue=false
3
6679
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 with the html <img> tag), I can make the image visible or not, i.e. '<img style="visibility='hidden'" src='xxxx'/>'. But if I create the image dynamically with javascript: new Image() then try to modify the style, Safari chokes, and the Debug...
7
2534
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, and because it lacks an internal debugger, I'm completely unable to see what the problem is. So I downloaded that "Drosera" debugging program, but I'm finding it useless for the following reasons: 1) I cannot "Attach" it to Safari 2.0...
1
3504
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. There is a small bit of javascript which, when the 'onChange' event occurs, triggers a 'submit' which reloads the page and displays the stored values for that session using a session ID variable named, '$existingSessions'. Even though the form's...
2
4744
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 = window.open("test.htm","foo");//, str); alert(win); does not open a new window and the value displayed by the alert is "undefined" (shouldn't it be "null" if there was a problem???). Also
15
2643
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. /
2
4767
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 I will. Let me illustrate the problem with examples. The HTML: <html> <head> <script type="text/javascript" src="/js/mootools_1_11.js"></script>
0
8401
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8404
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8054
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.