473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Convert javascript for Firefox

Hi

I use the following script in order to show/hide a section, and at the same
time to change a companion .gif with another:

function doExpand(paraNum,arrowNum){
if
(paraNum.style.display=="none"){paraNum.style.disp lay="";arrowNum.src="../../images/arrOn.gif"}
else {paraNum.style.display="none";arrowNum.src="../../images/arrOff.gif"}
}

and then in the body:
<div id="reltpc"><a href="javascript:;" onClick="doExpand(xplan1,ico1)"><img
id="ico1" src="../../images/arrOff.gif" alt="" width="10" height="9"
border="0"> Show Info</a></div>
<div id="xplan" style="display:none" onClick="doExpand(xplan,ico1)">
<p>text here</p>
<p>some more text here</p>
</div>

Furthermore, two more scripts are used in order to show/hide a section
without the image:

function doSection (secNum){
if (secNum.style.display=="none"){secNum.style.displa y="block"}
else{secNum.style.display="none"}
}

function noSection (secNum){
if (secNum.style.display=="block"){secNum.style.displ ay="none"}
}

and then in the body:
<div id="more"><a href="javascript:;" onClick="doSection(dtails1)">More
Info</a></div>
<div id="dtails1" style="display:none" onClick="noSection(dtails1)">
<p>text here</p>
<p>some more text here</p>
</div>

All three of them are working good in IE and Ffox, however the second claims
to use "gelElementById" instead.

Well, how could it be done? Would you help me please, to get that
conversion?

Thanks.

--
Merlin dying to the Lady of the Lake:
"We lived our lives with passion and devotion"
--
Please, remove hyphens to contact me
Jul 23 '05 #1
3 4318

Keep it concise and precise, lots of wording, little specifc explanation,
and the code looks very bloated, document.getElementById() is not
mozilla/firefox, is DOM1 by the way and most browsers process it fine.

Danny

On Sun, 12 Jun 2005 10:43:42 -0700, geotso <ka********@yahoo.gr> wrote:
Hi

I use the following script in order to show/hide a section, and at the
same
time to change a companion .gif with another:

function doExpand(paraNum,arrowNum){
if
(paraNum.style.display=="none"){paraNum.style.disp lay="";arrowNum.src="../../images/arrOn.gif"}
else
{paraNum.style.display="none";arrowNum.src="../../images/arrOff.gif"}
}

and then in the body:
<div id="reltpc"><a href="javascript:;"
onClick="doExpand(xplan1,ico1)"><img
id="ico1" src="../../images/arrOff.gif" alt="" width="10" height="9"
border="0"> Show Info</a></div>
<div id="xplan" style="display:none" onClick="doExpand(xplan,ico1)">
<p>text here</p>
<p>some more text here</p>
</div>

Furthermore, two more scripts are used in order to show/hide a section
without the image:

function doSection (secNum){
if (secNum.style.display=="none"){secNum.style.displa y="block"}
else{secNum.style.display="none"}
}

function noSection (secNum){
if (secNum.style.display=="block"){secNum.style.displ ay="none"}
}

and then in the body:
<div id="more"><a href="javascript:;" onClick="doSection(dtails1)">More
Info</a></div>
<div id="dtails1" style="display:none" onClick="noSection(dtails1)">
<p>text here</p>
<p>some more text here</p>
</div>

All three of them are working good in IE and Ffox, however the second
claims
to use "gelElementById" instead.

Well, how could it be done? Would you help me please, to get that
conversion?

Thanks.


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #2
geotso wrote:
Hi

I use the following script in order to show/hide a section, and at the same
time to change a companion .gif with another:

function doExpand(paraNum,arrowNum){
if
(paraNum.style.display=="none"){paraNum.style.disp lay="";arrowNum.src="../../images/arrOn.gif"}
else {paraNum.style.display="none";arrowNum.src="../../images/arrOff.gif"}
}
When posting code, please wrap manually at about 70 characters to
stop auto-wrapping.

and then in the body:
<div id="reltpc"><a href="javascript:;" onClick="doExpand(xplan1,ico1)"><img
id="ico1" src="../../images/arrOff.gif" alt="" width="10" height="9"
border="0"> Show Info</a></div>
<div id="xplan" style="display:none" onClick="doExpand(xplan,ico1)">


Here you are passing the id of the div 'xplan' to your function, then
using it as a global variable. This is an Microsoft-ism - Firefox
only supports it out of frustration that so many sites don't work if
it doesn't. You are doing the same thing with 'ico1'.

Since the onlcick is fired from the div that you are modifying, you
can use 'this'. To get a reference to the image, you will need to
use getElementById in your function, so the call is:

<div id="xplan" style="display:none" onClick="doExpand(this,'ico1')">

And your function:

function doExpand(paraNum,arrowNum){
var a = document.getElementByIt(arrowNum);
if (paraNum.style.display == "none" ){
paraNum.style.display = "";
arrowNum.src="../../images/arrOn.gif"
}

Read the group faq regarding support for getElementById for older
browsers.

<URL:http://www.jibbering.com/faq/#FAQ4_15>
--
Rob
Jul 23 '05 #3
RobG wrote:
[...]

Since the onlcick is fired from the div that you are modifying, you
can use 'this'. To get a reference to the image, you will need to
use getElementById in your function, so the call is:

<div id="xplan" style="display:none" onClick="doExpand(this,'ico1')">

And your function:

function doExpand(paraNum,arrowNum){
var a = document.getElementByIt(arrowNum);
Ooops, try:

arrowNum = document.getElementById(arrowNum);
if (paraNum.style.display == "none" ){
paraNum.style.display = "";
arrowNum.src="../../images/arrOn.gif"
}

--
Rob
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Howard Kaikow | last post by:
Yesterday, I decided to try Firefox. I've encountered a behavior that is either a bug in Firefox or a bug in my Javascript code. I'll try to explain the problem, hoping that this newsgroup can...
2
by: davidgordon | last post by:
Hi, I have some pages with this VBScript code, which obviously does not work in Firefox. How can I convert this to Javascript in order for my web page to work in Firefox ? It basically fills a...
13
by: John Smith | last post by:
I am using IE 6.0 from http://www.javaworld.com/javaworld/jw-07-1996/jw-07-javascript-p2.html I gather that "If you need to test a number of command lines, you can reduce the keystrokes by...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
4
by: lmarceglia | last post by:
Hi, I have this website that doesn't work in Firefox 1.5: www.pianetaluca.com The HTML source is: <TITLE>PianetaLuca</TITLE> </HEAD>
7
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
11
by: minnesotti | last post by:
Hi there, I subscribed to a photographic pictures-hosting website which is heavy on JavaScript. My preferred latest browser Mozilla Firefox does not work with it -- no pictures are displayed and...
8
by: Matt Kruse | last post by:
http://news.zdnet.com/2100-1009_22-6121608.html Hackers claim zero-day flaw in Firefox 09 / 30 / 06 | By Joris Evers SAN DIEGO--The open-source Firefox Web browser is critically flawed in...
16
by: Eric | last post by:
I have a user of a web application written in Java/JSP that is unable to login to the site simply because certain links on the page do not run when they are clicked. Other popups using Javascript...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.