Hi,
I have tried several things to get firefox show a bullet list (<ulwhen I
click on the list
having
1) <div onclick="javasc ript....">
2) <a href="javascrip t:..."
(see full HTML below!)
but in both cases, the swapP function is not triggered.
Why does firefox not bother about this?
<script language="javas cript" type="text/javascript">
function swapP(obj)
{var testit = obj.style.displ ay;
if ( testit == undefined) return false;
obj.style.displ ay = testit == 'block' ? 'none' : 'block';
}
</script>
(snippet)
<li>
<a id="_ctl0_conte nt_faqList__ctl 1_issue"
href="javascrip t:swapP(_ctl0_c ontent_faqList_ _ctl1_answer);" >
blah question blah blah ?
</a>
<div id="_ctl0_conte nt_faqList__ctl 1_answer" class="answer">
blha blah blah answer
</div>
</li>
(class answer is inside a css where div.answer {display=none;} 5 7288
basanistes said the following on 7/28/2006 1:18 PM:
Hi,
I have tried several things to get firefox show a bullet list (<ulwhen
I click on the list
having
1) <div onclick="javasc ript....">
2) <a href="javascrip t:..."
(see full HTML below!)
but in both cases, the swapP function is not triggered.
Why does firefox not bother about this?
It does, but view the error console.
<script language="javas cript" type="text/javascript">
function swapP(obj)
{var testit = obj.style.displ ay;
var testit=document .getElementById (obj).style.dis play
As the "obj" you pass is not the object, but rather the ID of the
object. Well, except in IE.
<a id="_ctl0_conte nt_faqList__ctl 1_issue"
href="javascrip t:swapP(_ctl0_c ontent_faqList_ _ctl1_answer);" >
First problem is the id of the object is not quoted in the function call.
Second problem is that IE is only browser with the ignorance built in to
create a global reference to any object with an ID.
Third problem is the use of the javascript : pseudo-protocol.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
basanistes wrote:
but in both cases, the swapP function is not triggered.
Why does firefox not bother about this?
<a id="_ctl0_conte nt_faqList__ctl 1_issue"
href="javascrip t:swapP(_ctl0_c ontent_faqList_ _ctl1_answer);" >
Since the JavaScript variable "_ctl0_content_ faqList__ctl1_i ssue" is not
defined.
There are two reasons for this:
1: The first character of an id must NOT be an underscore. http://www.w3.org/TR/html4/types.html#type-name
2: Firefox does not automatically create, for each element with an id, a
variable in the global scope named after that id and containing a reference
to the element. http://www.mozilla.org/docs/web-deve...ade_2.html#dom
--
David Dorward <http://blog.dorward.me .uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
"David Dorward" <do*****@yahoo. comwrote in message
news:ea******** ***********@new s.demon.co.uk.. .
basanistes wrote:
>but in both cases, the swapP function is not triggered. Why does firefox not bother about this?
> <a id="_ctl0_conte nt_faqList__ctl 1_issue" href="javascrip t:swapP(_ctl0_c ontent_faqList_ _ctl1_answer);" >
Since the JavaScript variable "_ctl0_content_ faqList__ctl1_i ssue" is not
defined.
As I told that I did not include the whole page. Of course, you can assume
that I''m not that 'stupid' :)
There are two reasons for this:
1: The first character of an id must NOT be an underscore.
that must have been the reason then. http://www.w3.org/TR/html4/types.html#type-name
2: Firefox does not automatically create, for each element with an id, a
variable in the global scope named after that id and containing a
reference
to the element.
http://www.mozilla.org/docs/web-deve...ade_2.html#dom
--
David Dorward <http://blog.dorward.me .uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
"Randy Webb" <Hi************ @aol.comwrote in message
news:aI******** *************** *******@comcast .com...
basanistes said the following on 7/28/2006 1:18 PM:
>Hi,
I have tried several things to get firefox show a bullet list (<ulwhen I click on the list
having 1) <div onclick="javasc ript...."> 2) <a href="javascrip t:..." (see full HTML below!)
but in both cases, the swapP function is not triggered. Why does firefox not bother about this?
It does, but view the error console.
><script language="javas cript" type="text/javascript"> function swapP(obj) {var testit = obj.style.displ ay;
var testit=document .getElementById (obj).style.dis play
that did the trick.
Thanks!
As the "obj" you pass is not the object, but rather the ID of the object.
Well, except in IE.
This sounds ok. THe object is referenced by id.
> <a id="_ctl0_conte nt_faqList__ctl 1_issue" href="javascrip t:swapP(_ctl0_c ontent_faqList_ _ctl1_answer);" >
First problem is the id of the object is not quoted in the function call.
Second problem is that IE is only browser with the ignorance built in to
create a global reference to any object with an ID.
Third problem is the use of the javascript: pseudo-protocol.
So you mean that <div onclick=""etc should be better?
basanistes said the following on 7/28/2006 2:23 PM:
>
"Randy Webb" <Hi************ @aol.comwrote in message
news:aI******** *************** *******@comcast .com...
>basanistes said the following on 7/28/2006 1:18 PM:
<snip>
>> <a id="_ctl0_conte nt_faqList__ctl 1_issue" href="javascrip t:swapP(_ctl0_c ontent_faqList_ _ctl1_answer);" >
First problem is the id of the object is not quoted in the function call. Second problem is that IE is only browser with the ignorance built in to create a global reference to any object with an ID. Third problem is the use of the javascript: pseudo-protocol.
So you mean that <div onclick=""etc should be better?
<button onclick="">
<a href="noscript. html" onclick="someth ing();return false">
Anything is better than href="javascrip t:
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stewart |
last post by:
Hi Experts.
Please put the code sample below into an html document and take a look
at in NN6+. One span should be shown while the other is hidden.
Clicking the button should reverse this. However it doesn't.
Removing the table structure from around the text fixes it, but I need
the table structure (this is very simplified example).
Hope someone can provide an alternative?
|
by: Erwin Moller |
last post by:
Hi all,
Situation:
A (rather long) page that contains a lot of divs.
Some are visible (display:inline) at a certain time, other not.
The javascript is responsible for divs to be visible or not.
Question:
|
by: Erwin Moller |
last post by:
Hi group,
I have this obscure problem that really needs to be fixed, but I am out of
ideas.
Because the original script is very big, I'll try to summarize its
functionality.
Setup:
- many form-elements that will 'activate' a part of the form based on the
selection made.
|
by: Jake Barnes |
last post by:
Imagine I've this block of HTML:
<p>Alex Schein Mailing List <input type="checkbox"
name="newslettersToUse" value="133156"> (<a href="mcControlPanel.php"
onClick="hideOrShowDivById('emailList133156'); return false;">See
emails?</a>)</p>
<form method="post" action="mcControlPanel.php"
id="emailList133156" style="display:none;"><textarea
name="formInputs">nazjeehaj@son.org,
|
by: petermichaux |
last post by:
Hi,
I tried the following and everything worked fine.
element.style.position="relative";
Then I tried to make the CSS rule important and it didn't work. The
positioning was all wrong in Safari and very jerky in Firefox.
element.style.position="relative !important";
| |
by: RonY |
last post by:
I have a dropdown which calls SetTimePeriod method on change the selection. In the JS function, I reset the field style.display based on what the selection is. This works fine with IE but not working with Firefox browser.
The firefox browser has problem to display a field after its style.display is reset. At the end of the JS function, I printed out the fields style.display value. They are set correctly. How to resovle this?
My JS is :
...
|
by: Brian D |
last post by:
Take a look at this page. http://tempsite.texwipe.com/test/ The code
is too long to post here so just look at the source.
It works flawlessly in IE, but in Firefox not so much. Here is the
situation. I am using the javascript property style.display to show
and hide some div layers. These layer ids are Layer1, Layer2, Layer3,
etc. Each link on the left controls what is shown or hidden. When they
are clicked, the corresponding layer...
|
by: libsfan01 |
last post by:
function switch_display(switchme) {
var el = document.getElementById(switchme);
el.style.display = (el.style.display == 'none')? '' : 'none';
}
im using this function to switch the display on and off of a given
element. BUT if the element is set to 'none' to begin with then it wont
display it.
please help...
|
by: BClareS |
last post by:
Sorry, I have found my mistake, but I cannot delete this post.
I have discovered by experiment that element.style.top assignment in IE works with just a number on the right but in Firefox you have to put the unit too. Original code is below. Adding "+'px'" made it work in Firefox too.
javascript
var fullsizeimage = document.getElementById('fullsizeimageframe');
if (!fullsizeimage) return false;
var coord = new Array(2);
coord =...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |