473,406 Members | 2,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Safari 3 and refresh

I'm building a app in which opens in a new window without a menu bar or
tool bar. I need to warn users (who press the F5 key or Ctrl+R) that
refreshing may result in loss of data and to give them the option of
cancelling the refresh.

The code is relatively straightforward and works for IE, FF and Opera
but the intercept code is ignored by Safari 3.1 for Windows.

Following is part of the code that I'm using.

<script type="text/javascript">var sType = "keypress";</script>

<!--[if IE]>
<script type="text/javascript">sType = "keydown";</script>
<![endif]-->

<script type="text/javascript">

fIntercept = function(e) {
e = e || event.e;
if (e.keyCode == 116) {
// When F5 is pressed
fCancel(e);
} else if (e.ctrlKey && e.keyCode == 82) {
// When ctrl is pressed with R
fCancel(e);
}
};

fCancel = function(e) {
if (e.preventDefault) {
e.stopPropagation();
e.preventDefault();
} else {
e.keyCode = 0;
e.returnValue = false;
e.cancelBubble = true;
}
return false;
};

fAddEvent = function(obj, type, fn) {
if (obj.addEventListener) {
obj.addEventListener(type, fn, false);
} else {
obj['e'+type+fn] = fn;
obj[type+fn] = function() {
obj['e'+type+fn](window.event);
}
obj.attachEvent('on'+type, obj[type+fn]);
}
};

fAddEvent(document, sType,fIntercept);

</script>
Is there anything that can be done to get Safari to behave?

Andrew Poulos
Jun 27 '08 #1
6 1550
pr
Andrew Poulos wrote:
I'm building a app in which opens in a new window without a menu bar or
tool bar. I need to warn users (who press the F5 key or Ctrl+R) that
refreshing may result in loss of data and to give them the option of
cancelling the refresh.

The code is relatively straightforward and works for IE, FF and Opera
but the intercept code is ignored by Safari 3.1 for Windows.

Following is part of the code that I'm using.

<script type="text/javascript">var sType = "keypress";</script>

<!--[if IE]>
<script type="text/javascript">sType = "keydown";</script>
<![endif]-->
[...]
>
Is there anything that can be done to get Safari to behave?
Not wanting to stir up that whole JavaScript Ninja thing again :-)
nevertheless you might find this useful: <URL:
http://ejohn.org/blog/keypress-in-safari-31/>.
Jun 27 '08 #2
VK
On Apr 22, 10:44 am, Andrew Poulos <ap_p...@hotmail.comwrote:
I'm building a app in which opens in a new window without a menu bar or
tool bar. I need to warn users (who press the F5 key or Ctrl+R) that
refreshing may result in loss of data and to give them the option of
cancelling the refresh.
What about right-click - context menu - Refresh or direct address bar
typing? (the address bar cannot be removed for IE7/8 for security
consideration).

I would highly suggest to use onbeforeunload instead that covers all
navigation away situations.

For Safari and Opera where "onbeforeunload" property is spoofed but
not implemented: it is just too bad for the leftovers of their
remaining users. Eventually they will migrate on some more usable
platforms - it takes just 2-3 big almost filled forms lost on
different sites as the practice shows. Some may have a different
opinion.

// IE + Firefox:

window.onbeforeunload = warnNavigateAway;

function warnNavigateAway() {
var message = ''.concat(
'You are attempting to navigate away ',
'from the current page.\n',
'If you leave now then ',
'all current data will be lost.');

if ((typeof event == 'object') && ('returnValue' in event)) {
event.returnValue = message;
}
else {
return message;
}
}
Jun 27 '08 #3
VK
On Apr 22, 4:49 pm, VK <schools_r...@yahoo.comwrote:
// IE + Firefox:
// + Camino of course for MacOS users
window.onbeforeunload = warnNavigateAway;

function warnNavigateAway() {
var message = ''.concat(
'You are attempting to navigate away ',
'from the current page.\n',
'If you leave now then ',
'all current data will be lost.');

if ((typeof event == 'object') && ('returnValue' in event)) {
event.returnValue = message;
}
else {
return message;
}

}
Jun 27 '08 #4
VK wrote:
On Apr 22, 4:49 pm, VK <schools_r...@yahoo.comwrote:
>// IE + Firefox:

// + Camino of course for MacOS users
There is also a Firefox version for Mac OS X. It would be easier (and
correct) to say Mozilla/5.0 (the codebase) or Gecko (the layout engine),
because there are much more browsers based on either than just Firefox and
Camino.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jun 27 '08 #5
VK
// + Camino of course for MacOS users
>
There is also a Firefox version for Mac OS X. It would be easier (and
correct) to say Mozilla/5.0 (the codebase) or Gecko (the layout engine),
because there are much more browsers based on either than just Firefox and
Camino.
Mozilla Foundation is an open source project. Anyone can take the
source http://developer.mozilla.org/en/docs...la_Source_Code
and to build yet another browser without any care of Mozilla feature
guidelines - as long as it uses the "generic globe" instead of "foxy
globe" logo and some other little copyright details. The process can
be rather easily automated with a randomizer added over some batch
script so one could produce up to 40 slightly different browsers per
hour depending on the CPU speed. :-)
This way it is pointless to name all Gecko-based browsers. I named
Camino because I know the project and because it is a reputable long-
existing brand I can suggest for MacOS. It is also the only one
natively running 3rd party browser plus with AppleScript support.
Jun 27 '08 #6
VK wrote:
>>// + Camino of course for MacOS users
There is also a Firefox version for Mac OS X. It would be easier (and
correct) to say Mozilla/5.0 (the codebase) or Gecko (the layout
engine), because there are much more browsers based on either than just
Firefox and Camino.

Mozilla Foundation is an open source project.
No, Mozilla Foundation is a non-profit organization that maintains an open
source project called Mozilla(/5.0).
Anyone can take the source
http://developer.mozilla.org/en/docs...la_Source_Code and to
build yet another browser [...] This way it is pointless to name all
Gecko-based browsers. [...]
That is exactly what I pointed out to you.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Jun 27 '08 #7

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

Similar topics

2
by: David | last post by:
On every web browser except Safari, this website works great. (Well, by "every" I mean Mozilla, Netscape, and Internet Explorer, for Mac and Windows). The site is: http://www.ruleofthirds.com ...
14
by: DU | last post by:
According to a recent post, it seems that Konqueror 3.1+ and Safari 1.1 support CSS3 opacity style property under a proprietary name: "Support for the CSS3 opacity (using -khtml-opacity)...
1
by: aquimr | last post by:
Hi, I'm using input hidden control's value in the javascript function. same code is working fine on all other browser except a specific version of safari(i.e.: MAC OS 10.3.7 and Safari 1.2.4)....
4
by: Paul W | last post by:
Hi - can someone point me to info on the issues/resolutions of supporting the safari browser? To help me understand, if I was developing pages in say FrontPage, what attributes would I set for...
5
by: Bill Cohagan | last post by:
I'm having some serious difficulties with my ASP.Net 2.0 app rendering in Safari 2.0.3. The most immediate problem is that the menu control doesn't seem to work at all, particularly the use of...
34
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.
21
by: Edward | last post by:
Hi All, I feel frustrated with one of my Customers who wants me to ensure that a dotnet web site I am building for them must be compatible to Apple's Safari browser! Safari is buggy and it...
1
by: Bigpond News Server | last post by:
I have built a website that uses frames and a heavy reliance on Java Script to modify framesets, frames and load pages on the fly. The site works fine when using the PC version of Internet...
4
by: maureen1708 | last post by:
Hi, A noob here so please be gentle :) I am revamping my dog's website (don't laugh, he's what got me off the couch to learn a little html/css in the first place). Everything seems to work...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.