hi all,
i do the following JS code: -
<script language="javascript">
-
-
function hideLevel(id) {
-
var thisLevel = document.getElementById(id);
-
thisLevel.style.display = "none";
-
}
-
-
function showLevel(id) {
-
var thisLevel = document.getElementById(id);
-
if ( thisLevel.style.display == "none") {
-
thisLevel.style.display = "block";
-
}
-
else {
-
hideLevel(id);
-
}
-
}
-
-
function hideAll() {
-
hideLevel("layer1");
-
hideLevel("layer2");
-
hideLevel("layer3");
-
-
}
-
</script>
-
as you see, when i click on some link - the div layer is showing, when i click back - it is hiding.
Firefox is showing nothing. When I click on the link it shows for a milli-second, then disappears.
What can You suggest, please?
14 5519
All I see that is wrong is your script type.
<script language="javascript">
Should be <script type="text/javascript">
IE doesn't care, because it uses jscript, but some other browsers need the
correct type
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-
<html>
-
<head>
-
<title>Untitled</title>
-
</head>
-
-
<style>
-
.box {width:50px; height:50px; border:1px solid #000}
-
</style>
-
-
<script>
-
-
function hideLevel(id) {
-
var thisLevel = document.getElementById(id);
-
thisLevel.style.display = "none";
-
}
-
-
function showLevel(id) {
-
var thisLevel = document.getElementById(id);
-
if ( thisLevel.style.display == "none") {
-
thisLevel.style.display = "block";
-
}
-
else {
-
hideLevel(id);
-
}
-
}
-
-
function hideAll() {
-
hideLevel("layer1");
-
hideLevel("layer2");
-
hideLevel("layer3");
-
-
}
-
</script>
-
-
<body>
-
-
<div class="box" id="layer1"></div>
-
<div class="box" id="layer2"></div>
-
<div class="box" id="layer3"></div>
-
-
<a href="javascript:void(0)" onclick="hideAll()">Hide all</a>
-
<a href="javascript:void(0)" onclick="hideLevel('layer1')">Hide 1</a>
-
<a href="javascript:void(0)" onclick="hideLevel('layer2')">Hide 2</a>
-
<a href="javascript:void(0)" onclick="hideLevel('layer3')">Hide 3</a>
-
<a href="javascript:void(0)" onclick="showLevel('layer1')">Show 1</a>
-
<a href="javascript:void(0)" onclick="showLevel('layer2')">Show 2</a>
-
<a href="javascript:void(0)" onclick="showLevel('layer3')">Show 3</a>
-
-
</body>
-
</html>
-
-
everything worked just fine for me!
here is my complete code: -
-
ok. here is the complete code:
-
-
-------------------------------------------------------------------
-
<html>
-
-
<head>
-
-
<script language=javascript type='text/javascript'>
-
-
function hideDiv()
-
-
{
-
if (document.getElementById) { // DOM3 = IE5, NS6
-
document.getElementById('hideShow').style.visibility = 'hidden';
-
}
-
else {
-
if (document.layers) { // Netscape 4
-
document.hideShow.visibility = 'hidden';
-
}
-
else { // IE 4
-
document.all.hideShow.style.visibility = 'hidden';
-
}
-
}
-
}
-
-
function showDiv() {
-
if (document.getElementById) { // DOM3 = IE5, NS6
-
document.getElementById('hideShow').style.visibility = 'visible';
-
}
-
else {
-
if (document.layers) { // Netscape 4
-
document.hideShow.visibility = 'visible';
-
}
-
else { // IE 4
-
document.all.hideShow.style.visibility = 'visible';
-
}
-
}
-
}
-
</script>
-
-
<body onLoad = "javascript:hideDiv();">
-
-
<div>
-
-
<a href onClick="showDiv('hideShow');" style="cursor: hand">
-
<img src = "file://D:/webroot/site_pics/bo.jpg"></a>
-
</div>
-
-
<div id="hideShow">
-
<img src = "file://D:/webroot/site_pics/bo_big.jpg" onClick = "hideDiv('hideShow');">
-
</div>
-
-
</body>
-
</html>
-
-
----------------------------------------------------------------
interesting thing is that i have tried it without images, just with simple text - AND IT WORKS!
and when I insert images - no result.
This won't work:
<a href onClick="showDiv('hideShow');" style="cursor: hand">
The href isn't equal to anything. Also, change onClick to lower case.
In addition, 'hand' is not standard and IE only.
Other points:
1) I assume you are using a valid doctype? You will never get IE to pretend it's a modern browser without one.
You still need to change to this:
<script type="text/javascript">
interesting thing is that i have tried it without images, just with simple text - AND IT WORKS!
and when I insert images - no result.
That means it does work.
Firefox will not let you access local files using Javascript whilst IE does.
I'm afraid the only solution is to use web images, not images from your hard drive.
Even so, you should correct your errors as drhowarddrfine pointed out.
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-
<html>
-
<head>
-
<title>Untitled</title>
-
</head>
-
-
<style>
-
.box {width:50px; height:50px; border:1px solid #000}
-
</style>
-
-
<script>
-
-
function hideLevel(id) {
-
var thisLevel = document.getElementById(id);
-
thisLevel.style.display = "none";
-
}
-
-
function showLevel(id) {
-
var thisLevel = document.getElementById(id);
-
if ( thisLevel.style.display == "none") {
-
thisLevel.style.display = "block";
-
}
-
else {
-
hideLevel(id);
-
}
-
}
-
-
function hideAll() {
-
hideLevel("layer1");
-
hideLevel("layer2");
-
hideLevel("layer3");
-
-
}
-
</script>
-
-
<body>
-
-
<div class="box" id="layer1"></div>
-
<div class="box" id="layer2"></div>
-
<div class="box" id="layer3"></div>
-
-
<a href="javascript:void(0)" onclick="hideAll()">Hide all</a>
-
<a href="javascript:void(0)" onclick="hideLevel('layer1')">Hide 1</a>
-
<a href="javascript:void(0)" onclick="hideLevel('layer2')">Hide 2</a>
-
<a href="javascript:void(0)" onclick="hideLevel('layer3')">Hide 3</a>
-
<a href="javascript:void(0)" onclick="showLevel('layer1')">Show 1</a>
-
<a href="javascript:void(0)" onclick="showLevel('layer2')">Show 2</a>
-
<a href="javascript:void(0)" onclick="showLevel('layer3')">Show 3</a>
-
-
</body>
-
</html>
-
-
everything worked just fine for me!
yes. this helped, thanks a lot, man!
as i understood, the problem was "javascript :void(0)" - i removed it once from the code, and my problem repeated.
btw, your doctype is incomplete and puts IE into quirks mode. New pages should always use the strict doctype, too. Use this one:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
btw, your doctype is incomplete and puts IE into quirks mode. New pages should always use the strict doctype, too. Use this one:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
i will use
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
is this ok? cuz in strict i some table problems on the page...
Are transitioning older, deprecated code? Otherwise, fix your tables and use strict.
i use tables, not the layers yet.
in strict mode there are some padding problems, so i changed it to <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
you think i might have a lot of problems with it?
A doctype is not something to be changed. You always make the markup fit the doctype, not the doctype fit the markup. The doctype, essentially, is the set of rules you are coding to. You can't change the rules after you are done coding.
The padding issues are html/css and not javascript so you need to ask those questions there. But the complete code or a link is necessary.
hi guys... i just did anything but it dont want to work on FireFox... any other browser working fine... i need some help :( -
<script type="text/javascript">
-
-
var sliderwidth=400 //Specify the slider's width (in pixels)
-
var sliderheight=145 //Specify the slider's height (in pixels, pertains only to NS)
-
var slidespeed=4 //Specify the slider's scroll speed (larger is faster)
-
var pocet=14
-
var finalslide=""
-
var leftrightslide=new Array() //Specify the slider's images
-
-
-
for (a=0;a<pocet;a++){
-
leftrightslide[a]="<a onclick={images.obr.src=\"images/"+a+".jpg\"}> <img src=images/"+a+".jpg border=1 height=\"50\"></a>"
-
}
-
-
-
var copyspeed=slidespeed
-
for (i=0;i<leftrightslide.length;i++)
-
finalslide=finalslide+leftrightslide[i]+" "
-
if (document.all){
-
document.write('<marquee id=ieslider scrollAmount=0 style="width:'+sliderwidth+'">'+finalslide+'</marquee>')
-
ieslider.onmouseover=new Function("ieslider.scrollAmount=0")
-
ieslider.onmouseout=new Function("if (document.readyState=='complete') ieslider.scrollAmount=slidespeed")
-
}
-
function regenerate(){
-
window.location.reload()
-
}
-
function regenerate2(){
-
if (document.layers){
-
document.ns_slider01.visibility="show"
-
setTimeout("window.onresize=regenerate",450)
-
intializeleftrightslide()
-
}
-
if (document.all)
-
ieslider.scrollAmount=slidespeed
-
}
-
function intializeleftrightslide(){
-
document.ns_slider01.document.ns_slider02.document.write('<nobr>'+finalslide+'</nobr>')
-
document.ns_slider01.document.ns_slider02.document.close()
-
thelength=document.ns_slider01.document.ns_slider02.document.width
-
scrollslide()
-
}
-
function scrollslide(){
-
if (document.ns_slider01.document.ns_slider02.left>=thelength*(-1)){
-
document.ns_slider01.document.ns_slider02.left-=slidespeed
-
setTimeout("scrollslide()",100)
-
}
-
else{
-
document.ns_slider01.document.ns_slider02.left=sliderwidth
-
scrollslide()
-
}
-
}
-
window.onload=regenerate2
-
-
//-->
-
</script>
-
-
-
<ilayer width=&{sliderwidth}; height=&{sliderheight}; name="ns_slider01" visibility=hide>
-
<layer name="ns_slider02" onMouseover="slidespeed=0;" onMouseout="slidespeed=copyspeed"></layer>
-
</ilayer>
-
-
<img src="images/0.jpg" border="1" height="75%" alt="Fotos" name="obr">
-
it may be a problem in <layer> and <ilayer> at the end... im realy wondering how to make it works in firefox :(...
u can simply try it.. make some directory, in there place index.htm what include this script and make a subdirectory "images" what will include files from 0.jpg to 14.jpg
it may be a problem in <layer> and <ilayer> at the end... im realy wondering how to make it works in firefox
Yes, you will need to replace the ilayer/layer with a div element. The code is also very old. To refer to elements use document.getElementById().
If you didn't write this code, just get a modern version of this script.
As acoder said, there is no such thing as <layer> or <ilayer>
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: Stewart |
last post by:
Originally posted in comp.lang.javascript:
Newsgroups: comp.lang.javascript
From: "Stewart"
Date: 23 Aug 2005 02:50:04 -0700
Local: Tues, Aug 23 2005 10:50 am
Subject: FireFox, RemoveChild,...
|
by: niconedz |
last post by:
Hi
The following code works fine in IE but not Firefox.
It's a little script that zooms an image and resizes the window to fit.
Can anybody tell me what's wrong?
Thanks
Nico
== btw.....
|
by: Pat |
last post by:
its seems asp.net validation doesn't fire when using FireFox?
Tested a page and it doesn't fire.
It seems the javascript doesn't fire
Any ideas?
|
by: Mark Olbert |
last post by:
The doPostBack javascript functioning is not submitting the page when called by linkbuttons (or an
autopostback checkbox, for that matter).
I'm aware of a problem with Netscape browsers and the...
|
by: petermichaux |
last post by:
Hi,
I'm hoping for a reason I'm wrong or an alternate solution...
I'd like to be able to dynamically include some javascript files. This
is like scriptaculous.js library but their solution is...
|
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>
|
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...
|
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...
|
by: SAL |
last post by:
Hello, I did google this issue and found some stuff related to BrowserCaps
section of either web.config or machine.config but it didn't work.
It seems that most pages in my webapp are okay but a...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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: 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,...
|
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...
| |