/    Sign up×
Community /Pin to ProfileBookmark

document about firefox javascript

i need to use javascript for firefox.
if u have something about this.
plez send to me.

[email][email protected][/email]

sorry my language so bad.

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 21.2005 — Basically, JavaScript is JavaScript without consideration for the browser. The only exception to this is in IE -- but, even then, what works in the other browsers will also work in IE 99% of the time. So, is it just plain JavaScript you really want to know about?
Copy linkTweet thisAlerts:
@maxdezignauthorApr 21.2005 — i want to use layer in firefox

i want to know function for write layer hide layer show layer and set x,y in layer

now i can use this in ie bu this code error in firefox and ns

sorry my eng so bad
Copy linkTweet thisAlerts:
@phpnoviceApr 21.2005 — [code=html]
<div id="myLayer>
This is a layer.
</div>
[/code]

To hide it:
<i>
</i>document.getElementById("myLayer").style.display = "none";

To show it:
<i>
</i>document.getElementById("myLayer").style.display = "block";

To change the layer's text:
<i>
</i>document.getElementById("myLayer").firstChild.data = "This is MY layer.";
Copy linkTweet thisAlerts:
@phpnoviceApr 29.2005 — Cheers.
Copy linkTweet thisAlerts:
@pizzaluvaMay 16.2005 — I'm still having some problems with this..

could you check out my page at :

http://www.welovewinter.com/showhidelayer.html

I'm not exactly a developer, so i'm pretty clueless with some things..

ANy help would be greatly appreciated!

works fine in IE, but not at all in firefox.


[CODE]<script language="JavaScript">
<!--
var NN4 = document.layers? true : false;
var IE4 = document.all? true : false;
var FF = document.getElementById? true : false;
var left;
var top;

function display(layerName) {
if (IE4) {
document.all[layerName].style.visibility = "visible";
}
else if(NN4) {
document.layers[layerName].visibility = "show";
}
else if(FF) {
document.getElementById('layer1').style.display = "block";
}
}

function hide() {
if (IE4) {
document.all['layer1'].style.visibility = "hidden";
}
else if(NN4) {
document.layers['layer1'].visibility = "hidden";
}
else if(FF) {
document.getElementById("layer1").style.display = "none";
}
}


// -->
</script>










[/CODE]
Copy linkTweet thisAlerts:
@phpnoviceMay 17.2005 — I'd suggest rearranging this:
<i>
</i>function display(layerName) {
if (IE4) {
document.all[layerName].style.visibility = "visible";
}
else if(NN4) {
document.layers[layerName].visibility = "show";
}
else if(FF) {
document.getElementById('layer1').style.display = "block";
}
}

into this:
<i>
</i>function display(id) {
if (document.getElementById) {
document.getElementById(id).style.display = "block";
}
else if (document.layers) {
document.layers[id].visibility = "show";
}
else if (document.all) {
document.all[id].style.visibility = "visible";
}
else {
alert('Unknown browser category.');
}
}

and likewise:
<i>
</i>function hide(id) {
if (document.getElementById) {
document.getElementById(id).style.display = "none";
}
else if (document.layers) {
document.layers[id].visibility = "hide";
}
else if (document.all) {
document.all[id].style.visibility = "hidden";
}
else {
alert('Unknown browser category.');
}
}
Copy linkTweet thisAlerts:
@pizzaluvaMay 17.2005 — that didn't seem to work.. actually now it won't work in IE.


heres what i have:

[CODE]<script language="JavaScript">
<!--

var left;
var top;

function display(id) {
if (document.getElementById) {
document.getElementById(id).style.display = "block";
}
else if (document.layers) {
document.layers[id].visibility = "show";
}
else if (document.all) {
document.all[id].style.visibility = "visible";
}
else {
alert('Unknown browser category.');
}
}

function hide(id) {
if (document.getElementById) {
document.getElementById(id).style.display = "none";
}
else if (document.layers) {
document.layers[id].visibility = "hide";
}
else if (document.all) {
document.all[id].style.visibility = "hidden";
}
else {
alert('Unknown browser category.');
}
}


// -->
</script>



<head>
<body>

<table width="500" border="1">
<tr>
<td align="center" class="tiny" bgcolor="#ff0000"
style="cursor: pointer" onclick=' display("layer1")'
onMouseOver="this.style.backgroundColor='000040';
return
true;" onMouseOut="this.style.backgroundColor='#ff0000';"><font color="white">SHOW WINDOW</font></td>
</tr>
</table>




<div id="layer1" style="left:305px; position:absolute; top:205px; visibility:hidden; z-index:0">
<table width="500" bgcolor="blue" height="300" border="2">
<tr>
<td height="30" align="center" class="tiny" bgcolor="#ff0000"
style="cursor: pointer" onclick=' hide("layer1")'
onMouseOver="this.style.backgroundColor='000040';
return
true;" onMouseOut="this.style.backgroundColor='#ff0000';"><font color="white">CLOSE WINDOW</font></td>
</tr>

<tr><td>LAYER 1 TABLE</td></tr>
</table>
</div>[/CODE]
Copy linkTweet thisAlerts:
@phpnoviceMay 17.2005 — Change the quotes on these:

onclick=' display("layer1")'

to be like this:

onclick="display('layer1')"

Although, technically, you should add [b]return true;[/b] to the end of each function and code the events as follows:

onclick="return display('layer1')"
Copy linkTweet thisAlerts:
@phpnoviceMay 17.2005 — I reworked your source a bit so that it will work now:
[code=html]
<script language="javascript" type="text/javascript">
<!--//
function display(id) {
if (document.getElementById) {
document.getElementById(id).style.display = "block";
}
else if (document.layers) {
document.layers[id].visibility = "show";
}
else if (document.all) {
document.all[id].style.visibility = "visible";
}
else {
alert('Unknown browser category.');
}
return true;
}

function hide(id) {
if (document.getElementById) {
document.getElementById(id).style.display = "none";
}
else if (document.layers) {
document.layers[id].visibility = "hide";
}
else if (document.all) {
document.all[id].style.visibility = "hidden";
}
else {
alert('Unknown browser category.');
}
return true;
}
//-->
</script>
<head>

<body>

<table width="500" border="1">
<tr>
<td align="center" class="tiny" bgcolor="#ff0000"
style="cursor: pointer" onclick="return display('layer1')"
onMouseOver="this.style.backgroundColor='#000040'; return true;"
onMouseOut="this.style.backgroundColor='#ff0000'; return true;">
<font color="white">SHOW WINDOW</font></td>
</tr>
</table>

<div id="layer1" style="position:absolute; left:305px; top:205px; z-index:0;">
<table width="500" bgcolor="blue" height="300" border="2">
<tr>
<td height="30" align="center" class="tiny" bgcolor="#ff0000"
style="cursor: pointer" onclick="return hide('layer1')"
onMouseOver="this.style.backgroundColor='#000040'; return true;"
onMouseOut="this.style.backgroundColor='#ff0000'; return true;">
<font color="white">CLOSE WINDOW</font></td>
</tr>
<tr><td>LAYER 1 TABLE</td></tr>
</table>
</div>

<script language="javascript" type="text/javascript">
<!--//
var x = hide('layer1');
//-->
</script>
[/code]
×

Success!

Help @maxdezign spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...