By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,842 Members | 2,440 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,842 IT Pros & Developers. It's quick & easy.

Safari and javascript

P: n/a
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
Sep 22 '05 #1
Share this Question
Share on Google+
13 Replies


P: n/a
ASM
Christine Forber wrote:
How can you make a div visible and hidden in safari?

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

Does not appear to work.


of course !
document.all
is Internet Explorer slang !

document.getElementById('div_submit").style.displa y = "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
Sep 22 '05 #2

P: n/a
ASM
ASM wrote:

what was have to read :

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

if div_submit
is the id of the div !
--
Stephane Moriaux et son [moins] vieux Mac
Sep 22 '05 #3

P: n/a
ASM wrote:
Christine Forber wrote:
How can you make a div visible and hidden in safari?

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

Does not appear to work.


of course !
document.all
is Internet Explorer slang !

document.getElementById('div_submit").style.displa y = "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)


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
Sep 22 '05 #4

P: n/a
Christine Forber <fi*******@lastname.net> wrote:
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?


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)cyberspace.org | don't, I need to know. Flames welcome.
Sep 22 '05 #5

P: n/a
ASM
Christine Forber wrote:
ASM wrote:
Christine Forber wrote:


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?


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
Sep 22 '05 #6

P: n/a

Christine Forber wrote:

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


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

Sep 22 '05 #7

P: n/a
On 22/09/2005 17:47, ASM wrote:

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


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.
Sep 22 '05 #8

P: n/a
ASM
Ian Osgood wrote:

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

defaults write com.apple.Safari IncludeDebugMenu 1
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)
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.
as : Use Transparent Window
You can then also use window.console.log("custom message") for your own
custom debugging messages.


thanks
--
Stephane Moriaux et son [moins] vieux Mac
Sep 22 '05 #9

P: n/a
Ian Osgood <ia**@quirkster.com> wrote:
Close Safari, open a Terminal window, and type at the prompt: defaults write com.apple.Safari IncludeDebugMenu 1


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)cyberspace.org | don't, I need to know. Flames welcome.
Sep 22 '05 #10

P: n/a
Christine Forber wrote:
ASM wrote:
Christine Forber wrote:

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

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

Does not appear to work.


of course !
document.all
is Internet Explorer slang !

document.getElementById('div_submit").style.disp lay = "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)

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?


Not really, I found that developing in Safari (pre 1.3) is a pain. The
tools available for Firefox a great and work pretty consistently on all
platforms so use that and just test in Safari.

It seems the tools for Safari have been greatly improved but I haven't
got the latest version and so can't comment on that.

But back to the question... how to debug in Sarari:

<URL:http://developer.apple.com/internet/safari/faq.html#anchor14>
--
Rob
Sep 22 '05 #11

P: n/a
RobG <rg***@iinet.net.au> wrote:
Not really, I found that developing in Safari (pre 1.3) is a pain. The
tools available for Firefox a great and work pretty consistently on all
platforms so use that and just test in Safari.
It's still a pain in 1.3, unless there is some way to get around the
fact that window.onerror doesn't work.
But back to the question... how to debug in Sarari: <URL:http://developer.apple.com/internet/safari/faq.html#anchor14>


I love how this FAQ is staying on the bleeding edge by validating
under the advanced HTML 4.01 Transitional specification.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Sep 23 '05 #12

P: n/a

Christopher Benson-Manica wrote:
Ian Osgood <ia**@quirkster.com> wrote:
Close Safari, open a Terminal window, and type at the prompt:

defaults write com.apple.Safari IncludeDebugMenu 1


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)cyberspace.org | don't, I need to know. Flames welcome.


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.quirksmode.org/js/events_compinfo.html#misc

Ian

Sep 23 '05 #13

P: n/a
Ian Osgood <ia**@quirkster.com> wrote:
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://ataru.gomen.org/scripterror.html

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)cyberspace.org | don't, I need to know. Flames welcome.
Sep 23 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.