473,748 Members | 6,412 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(paraNu m,arrowNum){
if
(paraNum.style. display=="none" ){paraNum.style .display="";arr owNum.src="../../images/arrOn.gif"}
else {paraNum.style. display="none"; arrowNum.src=". ./../images/arrOff.gif"}
}

and then in the body:
<div id="reltpc"><a href="javascrip t:;" onClick="doExpa nd(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="doExpa nd(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.d isplay=="none") {secNum.style.d isplay="block"}
else{secNum.sty le.display="non e"}
}

function noSection (secNum){
if (secNum.style.d isplay=="block" ){secNum.style. display="none"}
}

and then in the body:
<div id="more"><a href="javascrip t:;" onClick="doSect ion(dtails1)">M ore
Info</a></div>
<div id="dtails1" style="display: none" onClick="noSect ion(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 4353

Keep it concise and precise, lots of wording, little specifc explanation,
and the code looks very bloated, document.getEle mentById() 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********@yah oo.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(paraNu m,arrowNum){
if
(paraNum.style. display=="none" ){paraNum.style .display="";arr owNum.src="../../images/arrOn.gif"}
else
{paraNum.style. display="none"; arrowNum.src=". ./../images/arrOff.gif"}
}

and then in the body:
<div id="reltpc"><a href="javascrip t:;"
onClick="doExpa nd(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="doExpa nd(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.d isplay=="none") {secNum.style.d isplay="block"}
else{secNum.sty le.display="non e"}
}

function noSection (secNum){
if (secNum.style.d isplay=="block" ){secNum.style. display="none"}
}

and then in the body:
<div id="more"><a href="javascrip t:;" onClick="doSect ion(dtails1)">M ore
Info</a></div>
<div id="dtails1" style="display: none" onClick="noSect ion(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(paraNu m,arrowNum){
if
(paraNum.style. display=="none" ){paraNum.style .display="";arr owNum.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="javascrip t:;" onClick="doExpa nd(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="doExpa nd(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="doExpa nd(this,'ico1') ">

And your function:

function doExpand(paraNu m,arrowNum){
var a = document.getEle mentByIt(arrowN um);
if (paraNum.style. display == "none" ){
paraNum.style.d isplay = "";
arrowNum.src=". ./../images/arrOn.gif"
}

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

<URL:http://www.jibbering.c om/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="doExpa nd(this,'ico1') ">

And your function:

function doExpand(paraNu m,arrowNum){
var a = document.getEle mentByIt(arrowN um);
Ooops, try:

arrowNum = document.getEle mentById(arrowN um);
if (paraNum.style. display == "none" ){
paraNum.style.d isplay = "";
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
1945
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 (in)validate my Javascript code. First, I'll describe the purpose of the Javascript code. I often have a need to post a URL to something at my own web site, e.g., http://www.standards.com/Sorting/SortPerformanceComparison-Description.html. It is...
2
8913
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 drop down with a list of dates that a user can select. Appreciate any help you can offer ----------------------
13
8310
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 typing javascript: (remember the colon) in the Location box. Navigator displays a "JavaScript typein" frame at the bottom of the window. Type the command line you want to try, and press Enter. "
8
3674
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
4
2330
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
9615
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 language="JavaScript"> var cntlName; var eleTarget = document.getElementById('hiding'); function showOrHide(){
11
3431
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 no buttons react to clicking. The website's helpdesk says it should work with Firefox, and could not offer any more advices. The JavaScript Console shows that there are numerous errors occuring. It looks like the web browser does not recognise...
8
1928
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 the way it handles JavaScript, two hackers said Saturday afternoon. An attacker could commandeer a computer running the browser simply by crafting a Web page that contains some malicious JavaScript code, Mischa Spiegelmock and Andrew Wbeelsoi...
16
2333
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 on the same page work correctly. It appears to be isolated to 1-2 machines in a particular network. I cannot verify whether these machines have had virus/spyware scans, but I do know the user is running Firefox 2.1 and IE 7 with the same...
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9548
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9249
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 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...
0
8244
agi2029
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...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
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 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.