Gå til innhold

[Løst]Ødelagt spoiler HTML-kode.


Anbefalte innlegg

Jeg klarte nylig å "ødelegge" min spoiler HTML kode. (Eller koder, det er 3 i 1)

Den skal egentlig vise 3 trykkbare spoiler-knapper, men bare den øverste virker.. :(

Her kan dere se at den ikke funker.

 

Her er hele HTML-koden:

 

 

<html>
<head>
<title>Spoiler HTML code</title>
<style type="text/css">
body,input
{
font-family:"Trebuchet ms",arial;font-size:0.9em;
color:#333;
}
.spoiler
{
border:1px solid #ddd;
padding:3px;
}
.spoiler .inner
{
border:1px solid #eee;
padding:3px;margin:3px;
}
</style>
<script type="text/javascript">
function showSpoiler(obj)
{
var inner = obj.parentNode.getElementsByTagName("div")[0];
if (inner.style.display == "none")
	inner.style.display = "";
else
	inner.style.display = "none";
}
</script>
</head>
<body>
<h1></h1>
<div class="spoiler">
<input type="button" onclick="showSpoiler(this);" value="Click to show tutorials" />
<div class="inner" style="display:none;">
<b><br>- Build vehicles [WIP]<br><br>
- Stations [WIP]<br><br>
- Signals [WIP]<br><br>
<A HREF="http://bennythen00b.webs.com/openttdnewgrfs.htm">- NewGRFs</A><br><br><b>
</div>
</div>
</body>
</html>

<html>
<head>
<title>Spoiler HTML code</title>
<style type="text/css">
body,input
{
font-family:"Trebuchet ms",arial;font-size:0.9em;
color:#333;
}
.spoiler
{
border:1px solid #ddd;
padding:3px;
}
.spoiler .inner
{
border:1px solid #eee;
padding:3px;margin:3px;
}
</style>
<script type="text/javascript">
function showSpoiler(obj)
{
var inner = obj.parentNode.getElementsByTagName("div")[0];
if (inner.style.display == "none")
	inner.style.display = "";
else
	inner.style.display = "none";
}
</script>
</head>
<body>
<h1></h1>
<div class="spoiler">
<input type="button" onclick="showSpoiler(this);" value="Click to show links" />
<div class="inner" style="display:none;">

<b>
<br><A HREF="http://www.tt-forums.net">- TT-Forums</A><br><br>
<A HREF="http://wiki.openttd.org/Main_Page">- The OpenTTD wiki</A><br><br>
<A HREF="http://www.openttd.org"> - OpenTTD webpage</A><br><br>
<b>
</div>
</div>
</body>
</html>

<html>
<head>
<title>Spoiler HTML code</title>
<style type="text/css">
body,input
{
font-family:"Trebuchet ms",arial;font-size:0.9em;
color:#333;
}
.spoiler
{
border:1px solid #ddd;
padding:3px;
}
.spoiler .inner
{
border:1px solid #eee;
padding:3px;margin:3px;
}
</style>
<script type="text/javascript">
function showSpoiler(obj)
{
var inner = obj.parentNode.getElementsByTagName("div")[0];
if (inner.style.display == "none")
	inner.style.display = "";
else
	inner.style.display = "none";
}
</script>
</head>
<body>
<h1></h1>
<div class="spoiler">
<input type="button" onclick="showSpoiler(this);" value="Click to show OpenTTD downloads" />
<div class="inner" style="display:none;">
<b>
<br><A HREF="http://www.openttd.org/en/download-stable">- Latest stable (0.7.0)</A><br><br>
<A HREF="http://www.openttd.org/en/download-trunk">- Latest nightly</A><br><br>
<A HREF="http://www.openttd.org/en/download-cargodest">- Latest Cargodest</A><br><br>
<b>
</div>
</div>
</body>
</html>

 

 

EDIT: Jeg driver og tester noen andre spoiler HTML-koder nå.

EDIT2: Fikset. :)

Endret av Bennythen00b
Lenke til kommentar
Videoannonse
Annonse

Jeg har nå prøvd med en annen kode, med samme resultat.. Firefox åpner bare den første spoileren.. :(

 

Kode #2:

 

 

<html>
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px"><b>Tutorials:</b> 
<input type='button'  value="Show" style="width:45px;font-size:10px;margin:0px;padding:0px;" onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') 
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';		this.innerText = ''; this.value = 'Hide'; } else 
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }">
</div>
<div class="alt2" style="margin: 0px; padding: 6px; border: 1px inset;">
<div style="display: none;">
<b><br>- Build vehicles [WIP]<br><br>
- Signals [WIP]<br><br>
- Stations [WIP]<br><br>
<A HREF="http://bennythen00b.webs.com/openttdnewgrfs.htm">- NewGRFs</A><br><br><b>
</div>
</div>
</div>
</html>


<html>
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px"><b>Links:</b> 
<input type='button'  value="Show" style="width:45px;font-size:10px;margin:0px;padding:0px;" onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') 
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';		this.innerText = ''; this.value = 'Hide'; } else 
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }">
</div>
<div class="alt2" style="margin: 0px; padding: 6px; border: 1px inset;">
<div style="display: none;">
<b>
<br><A HREF="http://www.tt-forums.net">- TT-Forums</A><br><br>
<A HREF="http://wiki.openttd.org/Main_Page">- The OpenTTD wiki</A><br><br>
<A HREF="http://www.openttd.org"> - OpenTTD webpage</A><br><br>
<b>
</div>
</div>
</div>
</html>


<html>
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px"><b>Downloads:</b> 
<input type='button'  value="Show" style="width:45px;font-size:10px;margin:0px;padding:0px;" onClick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') 
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';		this.innerText = ''; this.value = 'Hide'; } else 
{ this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Show'; }">
</div>
<div class="alt2" style="margin: 0px; padding: 6px; border: 1px inset;">
<div style="display: none;">
<b>
<br><A HREF="http://www.openttd.org/en/download-stable">- Latest stable (0.7.0)</A><br><br>
<A HREF="http://www.openttd.org/en/download-trunk">- Latest nightly</A><br><br>
<A HREF="http://www.openttd.org/en/download-cargodest">- Latest Cargodest</A><br><br>
<b>
</div>
</div>
</div>
</html>

 

Lenke til kommentar

Ja du har vel klart å kopiere headingen ned i body minst 2 ganger - det skal ikke være style eller title der, og funksjonen ShowSpoiler skal bare være definert i headingen. Noe sånt, det ser ut til å fungere både i IE og Firefox. (sorry for alle de blanke linjene det er Kompozer som gjør det):

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <title>Spoiler HTML code</title>


 <style type="text/css">
body,input
{
font-family:"Trebuchet ms",arial;font-size:0.9em;
color:#333;
}
.spoiler
{
border:1px solid #ddd;
padding:3px;
}
.spoiler .inner
{
border:1px solid #eee;
padding:3px;margin:3px;
}
 </style>
 <script type="text/javascript">
function showSpoiler(obj)
{
var inner = obj.parentNode.getElementsByTagName("div")[0];
if (inner.style.display == "none")
inner.style.display = "";
else
inner.style.display = "none";
}
 </script>
</head>
<body>

<div class="spoiler">
<input onclick="showSpoiler(this);" value="Click to show tutorials" type="button">
<div class="inner" style="display: none;"><br>

- Build vehicles [WIP]<br>

<br>

- Stations [WIP]<br>

<br>

- Signals [WIP]<br>

<br>

<a href="http://bennythen00b.webs.com/openttdnewgrfs.htm">-
NewGRFs</a><br>

<br>

</div>

</div>

<div class="spoiler">
<input onclick="showSpoiler(this);" value="Click to show links" type="button">
<div class="inner" style="display: none;"><br>

<a href="http://www.tt-forums.net">- TT-Forums</a><br>

<br>

<a href="http://wiki.openttd.org/Main_Page">- The OpenTTD
wiki</a><br>

<br>

<a href="http://www.openttd.org"> - OpenTTD webpage</a><br>

<br>

</div>

</div>

<div class="spoiler">
<input onclick="showSpoiler(this);" value="Click to show OpenTTD downloads" type="button">
<div class="inner" style="display: none;"><br>

<a href="http://www.openttd.org/en/download-stable">-
Latest stable (0.7.0)</a><br>

<br>

<a href="http://www.openttd.org/en/download-trunk">-
Latest nightly</a><br>

<br>

<a href="http://www.openttd.org/en/download-cargodest">-
Latest Cargodest</a><br>

<br>

</div>

</div>

</body>
</html>

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...