Safari and javascript

  • Follow


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
0
Reply Christine 9/22/2005 4:03:01 PM

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.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
0
Reply ASM 9/22/2005 4:04:50 PM


ASM wrote:

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
0
Reply ASM 9/22/2005 4:07:48 PM

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.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)

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
0
Reply Christine 9/22/2005 4:27:51 PM

Christine Forber <firstname@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.
0
Reply Christopher 9/22/2005 4:46:49 PM

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
0
Reply ASM 9/22/2005 4:47:00 PM

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

0
Reply Ian 9/22/2005 5:03:43 PM

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.
0
Reply Michael 9/22/2005 5:08:18 PM

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
0
Reply ASM 9/22/2005 5:22:05 PM

Ian Osgood <iano@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.
0
Reply Christopher 9/22/2005 5:50:58 PM

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.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)
> 
> 
> 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
0
Reply RobG 9/22/2005 11:32:17 PM

RobG <rgqld@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.
0
Reply Christopher 9/23/2005 2:59:02 AM

Christopher Benson-Manica wrote:
> Ian Osgood <iano@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

0
Reply Ian 9/23/2005 5:06:50 PM

Ian Osgood <iano@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.
0
Reply Christopher 9/23/2005 6:01:44 PM

13 Replies
319 Views

(page loaded in 0.168 seconds)

Similiar Articles:


















7/20/2012 8:22:32 PM


Reply: