Bug with firefox

G

GarryJones

I needed to hide and show som DIV sections,

There are many scripts on the net for this. I downloaded that allows
me to open a hidden DIV from inside a DIV than is itself hidden. This
accomplished I was pleased with my work.

That was until I saw the mess in Firefox which ignores everything I
tell it to do and opens all the DIVs regardless on load. Forgetting
the browser war jargon as to why Firefox would release a program that
doesn't work with common code I just need a way of doing this so it
works in Firefox AND MSIE and anything else out there.

function InsertContentmed(tid) {
if (
document.getElementById(tid).style.display == "none") {
document.getElementById(tid).style.display = "";
document.regfrms.cgfnm.focus();
}
else {
document.getElementById(tid).style.display = "none";
}
}

I am opening and closing a hidden DIV with a click call. (It opens it
when it is closed and it closes it when it is open, The other standard
way of doing this does not work for me as I need this to work from
withing a parent DIV that is itself opened by another Javascript
function.

Any and all help greatly appreciated

Garry Jones
Sweden
 
G

GarryJones

Solved!

I was having trouble earlier when I wrote this code so I changed a
couple of <DIV> tags to <p> tags. It was these that were faulting.

Firefox does not allow <p> tags to have a [ style="display: none" ]
component. Strange but true, when turned back to DIV it works
perfectly (even on MSIE). I dread to see my site on other browsers but
know I must......

Sorry to have disturbed you good people.....

However, a wider issue and OT but these differing Internet browsers
are a headache, rather like a country allowing people to drive on the
left and ride side of the road at the same time. I dont care which one
but wouldn't life be jollier if all the companies making browsers bar
one gave up and deleted their products? What's the point of more than
one?

Cheers
Garry Jones
Sweden
 
T

Thomas 'PointedEars' Lahn

GarryJones said:

It only seems so. You have merely found a workaround to the problem as
caused by the insufficient analysis of it.
I was having trouble earlier when I wrote this code so I changed a couple
of <DIV> tags to <p> tags. It was these that were faulting.

Firefox does not allow <p> tags to have a [ style="display: none" ]
component.
Nonsense.

Strange but true, when turned back to DIV it works perfectly (even on
MSIE).

Which would indicate instead that either your markup or your script so far
Sorry to have disturbed you good people.....

Don't be sorry for *that*.


PointedEars
 
A

Arun

Firefox does not allow said:
Nonsense.

I agree with PointedEars. This claim is completely untrue. I wrote
the
following program and it works perfectly on all browsers I tested it
on.

...
<head>
...
<script type="text/javascript" language="JavaScript">
function toggle_container(id)
{
var container = document.getElementById(id);
container.style.display = (container.style.display == "")
? "none" : "";
}
</script>
</head>
<body>
...
<a href="javascript:void(0);"
onclick="toggle_container('some_text');">Toggle</a>
<p id="some_text" style="display:;">Hello there</p>
...
</body>
...

Which would indicate instead that either your markup or your script so far
is of poor quality, for <p style="display: none">...</p> works fine in my Fx
3.0.1 and all other CSS-capable UAs.

I'd like to add that I checked this code on IE(5,6,7,8b) and
Firefox(infancy-3.0),
after all, checking for browser compatibility is kinda part of my job.
 
T

Thomas 'PointedEars' Lahn

Arun wrote:
^^^^^^^^^^^
You are encouraged to shorten the attribution line to ease reading, but
please do not remove it.
Firefox does not allow <p> tags to have a [ style="display: none" ]
component.
Nonsense.

I agree with PointedEars. This claim is completely untrue. I wrote
the following program and it works perfectly on all browsers I tested
it on.

Even though it is error-prone and invalid ;-)
[...]
<script type="text/javascript" language="JavaScript">
^^^^^^^^^^^^^^^^^^^^^
The `language' attribute is deprecated and unnecessary nowadays.
[...]
<a href="javascript:void(0);"
^^^^^^^^^^^^^^^^^^^
You should not do that said:
onclick="toggle_container('some_text');">Toggle</a>
^
There is where the `return' statement belongs.
<p id="some_text" style="display:;">Hello there</p>
^^^^^^^^^
There you may have syntactically Valid markup, but not Valid CSS;
in a CSS property declaration, the property value is *required*.

<http://jigsaw.w3.org/css-validator/>


HTH

PointedEars
 
A

Arun

Thomas 'PointedEars' Lahn said:
Even though it is error-prone and invalid ;-)

I agree that the code is error-prone but is sufficient as an example.
                                  ^^^^^^^^^^^^^^^^^^^^^
The `language' attribute is deprecated and unnecessary nowadays.

Because the `language' attribute is deprecated, it doesn't mean that
it
might not work. It is mainly there for backward compatibility. People
still
use browsers that can not evaluate MIME-types in attribute values.
[...]
 <a href="javascript:void(0);"

            ^^^^^^^^^^^^^^^^^^^
You should not do that said:
onclick="toggle_container('some_text');">Toggle</a>

^
There is where the `return' statement belongs.

Thanks for the link. I never knew all that stuff. I'll be sure to
clean up my act in days to come.

Thanks again,
Arun
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>, Mon,
1 Sep 2008 23:53:02 said:
Arun wrote:
^^^^^^^^^^^
You are encouraged to shorten the attribution line to ease reading, but
please do not remove it.

The OP is encouraged to ignore your various manias, Herr KontrolleFreak,
and to use a decently informative attribution line, as has (as you know)
been recommended by those who are mote intelligent, mature, and
experienced than yourself.
 
T

Thomas 'PointedEars' Lahn

Arun said:
I agree that the code is error-prone but is sufficient as an example.

There is a contradiction.
Because the `language' attribute is deprecated, it doesn't mean that
it might not work.

It makes no difference but in MSHTML with the value of "VBScript", and in
Mozilla with the value of "JavaScript1.2".
It is mainly there for backward compatibility.

Backwards compatibility to an obsolete standard that did not even define the
attribute in the first place? Think again.
People still use browsers that can not evaluate MIME-types in attribute values.

Name one.

Besides, it does not matter whether they can "evaluate MIME-types in
attribute values". Where the `type' attribute is ignored, an ECMAScript
implementation is the default (because at the time of shipping only
available) client-side scripting language. Where it is not, the HTML 4.01
standard was implemented.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,002
Messages
2,570,261
Members
46,858
Latest member
FlorrieTuf

Latest Threads

Top