Safari and javascript

javascript

Safari and javascript

Postby Christine Forber » Sat, 24 Sep 2005 01:03:01 GMT

How can you make a div visible and hidden in safari?

document.all["div_submit"].style.display = "none";

Does not appear to work.

Also, can anyone tell me how to turn on javascript error commenting in
Safari? Right now, if javascript fails or errors, the browser just sits
there and doesn't return any error message.

-- 
Christine

Re: Safari and javascript

Postby ASM » Sat, 24 Sep 2005 01:04:50 GMT



of course !
    document.all
is Internet Explorer slang !

document.getElementById('div_submit").style.display = "none";

and ... miracle ... it is also understood by IE :-)

get FireFox and its add-on : "Web developer"
to fix your pb of JS console (and much more)

-- 
Stephane Moriaux et son [moins] vieux Mac

Re: Safari and javascript

Postby ASM » Sat, 24 Sep 2005 01:07:48 GMT



what was have to read :

document.getElementById('div_submit').style.display = "none";

if div_submit
is the id of the div !


-- 
Stephane Moriaux et son [moins] vieux Mac

Re: Safari and javascript

Postby Christine Forber » Sat, 24 Sep 2005 01:27:51 GMT





Thank you, I've relayed this response to my colleague. Re your
suggestion about FireFox, is it close enough to Safari to detect js
problems that would cause problems in Safari too?

-- 
Christine

Re: Safari and javascript

Postby Christopher Benson-Manica » Sat, 24 Sep 2005 01:46:49 GMT




It will certainly catch the vast majority of IE-specific script (for
example, uses of the document.all object), but AFAIK Safari uses a
script engine that is not based on anything used by Firefox.  Both aim
for a good approximation of standards compliance, so script that runs
on Firefox has a good chance of running on Safari, but there are no
guarantees.

-- 
Christopher Benson-Manica  | I *should* know what I'm talking about - if I
ataru(at){*filter*}space.org    | don't, I need to know.  Flames welcome.

Re: Safari and javascript

Postby ASM » Sat, 24 Sep 2005 01:47:00 GMT






except IE's slang,

generaly javascript (and beter DOM) is javascript

even for Apple :-)

fiew css3 understood by FF aren't by Safari
or not same way ...
  -moz-opacity: 0.3;      /* FF */
  -khtml-opacity: 0.3;    /* Safari */
  filter: blah blah; 30;  /* IE Windows */
  -moz-radius: 10px;
  radius: 10px;

it is Opera which could give some pb (as iCab)
(they can tell they ARE IE ! !)

in javascript jscript ->
sure detection if it is IE (all environnement and versions) :

   var ie = false;   /*@cc_on  ie = true;  @*/



-- 
Stephane Moriaux et son [moins] vieux Mac

Re: Safari and javascript

Postby Ian Osgood » Sat, 24 Sep 2005 02:03:43 GMT




Close Safari, open a Terminal window, and type at the prompt:

 defaults write com.apple.Safari IncludeDebugMenu 1

Now there will be a Debug menu as the rightmost menu in Safari. Check
"Log JavaScript Exceptions" and select "Show JavaScript Console".  Many
of the other items in the Debug menu are also useful.

You can then also use window.console.log("custom message") for your own
custom debugging messages.

Ian


Re: Safari and javascript

Postby Michael Winter » Sat, 24 Sep 2005 02:08:18 GMT



[snip]


I fail to see how browser detection is at all necessary. The OP simply 
needs to avoid IE-specific methods and properties, and to test on a 
range of browsers.

The closest browser to Safari would be Konqueror as the former uses the 
latter's rendering engine (I don't know if that includes scripting 
engine, though). Konqueror is part of the KDE windowing system for 
Linux, and can be used in Windows through Cygwin.

Mike

-- 
Michael Winter
Prefix subject with [News] before replying by e-mail.

Re: Safari and javascript

Postby ASM » Sat, 24 Sep 2005 02:22:05 GMT



wonderfull !
I didn't know that !
Great ! it works ! I have a new menu.

Is there a way to internationalize this menu ?
(to get it in french for instance)


as : Use Transparent Window


thanks


-- 
Stephane Moriaux et son [moins] vieux Mac

Re: Safari and javascript

Postby Christopher Benson-Manica » Sat, 24 Sep 2005 02:50:58 GMT





You know, I'd really be ecstatic if Apple did less "thinking
differently" and more making their product sane, say by supporting
window.onerror; I was going to suggest it to OP before I realized how
pathetically broken Safari is in this respect...

I'd love to be proven wrong on this, by the way :-)

-- 
Christopher Benson-Manica  | I *should* know what I'm talking about - if I
ataru(at){*filter*}space.org    | don't, I need to know.  Flames welcome.

Re: Safari and javascript

Postby Ian Osgood » Sun, 25 Sep 2005 02:06:50 GMT






I thought window.onerror had gone the way of the dodo.  quirksmode.org
reports that it no longer works in *any* modern browser.  I guess we
should be using try/catch/finally in these modern times. Only the
onerror handler for individual IMG elements seems to work reliably.

  http://www.**--****.com/ #misc

Ian


Re: Safari and javascript

Postby Christopher Benson-Manica » Sun, 25 Sep 2005 03:01:44 GMT




 http://www.**--****.com/ 

catches the script error in IE 6 and lower; in the IE 7 beta that I'm
running, "Display a notification about every script error" must be
enabled for the message to be displayed.  Firefox 1.0.4 and Netscape 8
both catch it.  Safari does not, nor does Opera 8.5.  I suppose the
consensus is mixed, but I would certainly not say that it's "gone the
way of the dodo", and it continues to be an extremely useful feature,
at least in my eyes.  Rather than littering code with try/except
blocks, it's very helpful to have a window.onerror to catch exceptions
and tell you where they happen.  We use it to add script errors to a
database for tracking and fixing bugs, and it's been very successful
(although it also alerts us to a variety of arcane situations).


-- 
Christopher Benson-Manica  | I *should* know what I'm talking about - if I
ataru(at){*filter*}space.org    | don't, I need to know.  Flames welcome.

Similar Threads:

1.Safari and JavaScript arrays

Hello,

I am querying the JavaScript community to learn if 
others are having problems with Safari[1] and JavaScript 
arrays:

myImages = [
    "images/image0.jpg",
    "images/image1.jpg",
    "images/image2.jpg",
];
                                                                                
then referenced like this:
                                                                                
    document.images[1].src = myImages[1];
                                                                                
Is this a known bug with Safari? Broken arrays?
                                                                                
(BTW the above works in every major browser's
recent version; those I have tried)
                                                                                
I can write a string literal into the src property:
                                                                                
    document.images[1].src = "images/image1.jpg";
                                                                                
and achieve image replacement, but not when the string
literal is referenced from an array.
                                                                                
What gives? Am I doing something Really Stupid (TM)?
                                                                                
Thanks in advance for advice.
                                                                                
Cheers,
DK
                                                                                
[1] Referring to Safari version 1.0.1
                                                                                

2.Safari (browser, Javascript) related forum?

3.Safari and javascript - turning on debug support

4.[OT] (was: Safari and javascript - turning on debug support)

5.fooling safari with javascript

Hi,
   Is it possible to fool Javascript running on a Mac Safari web
browser into believing it is a PC IE browser?  We have the following JS
code that is detecting both Mac and Safari.  Sadly, we do not have
control over the code.

// Global variables for platform branching
var NN, IE, MAC, browserVersion



// Flag to ensure that projectData document is loaded
var framesLoaded = false;

// Browser test
if (parseInt(navigator.appVersion) >= 4)
{
	if (navigator.appName == "Netscape")
		NN = true
	else
		IE = true
}
else
{
	// browser is to old
	alert("This page will not function properly in this browser because it
requires a browser version of 4.0 or above.");
}


// Version
if (IE) {
	browserVersion =
navigator.appVersion.charAt(navigator.appVersion.indexOf("MSIE") + 5);
}
else if (NN) {
	browserVersion = parseInt(navigator.appVersion);
}

// Computer test
if (navigator.appVersion.indexOf("Mac") != -1) {
	MAC = true;
}

if (NN && MAC) {
	alert("This activity cannot be used on a Macintosh running a Netscape
Web browser.");
	back();
}



Thanks, - Dave

6. Safari and JavaScript

7. Safari and Javascript

8. OS X 10.4.11 Latest Safari and Java update breaks stuff -- Including Thoth & Safari



Return to javascript

 

Who is online

Users browsing this forum: No registered users and 68 guest