04-27-2010, 08:29 PM
I'm learning the basics of HTML and PHP and I was wondering if there is a way to make spoilers work in HTML or PHP. I looked it up, and everything that people said to do wouldn't work for me.
(04-27-2010, 10:32 PM)Omniscient Wrote: [ -> ]Do you want spoilers for a forum or a website?
Basically it's a hidden div for the xhtml and the php would probably be a preg_replace.
(04-27-2010, 11:36 PM)daneasaur Wrote: [ -> ]I made one in my site. It's using a div thing. An easy way to find the source for one is add a spoiler to your post, then get the source code from that page, and Ctrl+F Spoiler or the contents of your spoiler. (That's how I did it)
<script type="text/javascript">
function Suite(lien){
var objet = document.getElementById('popup'); // In the ' you put the name of the div you want to hide
if(objet.style.display == "none" || !objet.style.display){
objet.innerHTML = "Text to show";
objet.style.display = "block";
objet.style.overflow = "hidden";
lien.innerHTML = "-";
var hFinal = 200; //Final Height
var hActuel = 0; //Initial Height
var timer;
var fct = function ()
{
hActuel += 20; //Height
objet.style.height = hActuel + 'px';
if( hActuel > hFinal)
{
clearInterval(timer); //We stop the timer
objet.style.overflow = 'inherit';
}
};
fct();
timer = setInterval(fct,40); //Every 40 ms
}else if(objet.style.display == "block"){
var hFinal = 0; //Final Height
var hActuel = 200; //Initial Height
var timer;
var fct = function ()
{
hActuel -= 20; //Height
objet.style.height = hActuel + 'px';
if( hActuel < hFinal)
{
clearInterval(timer); //We stop the timer
objet.style.overflow = 'inherit';
objet.style.display = "none";
}
};
fct();
timer = setInterval(fct,40); //Every 40 ms
lien.innerHTML = "+";
}
}
</script>
[<a href="javascript:;" onclick="Suite(this)">+</a>]
<div id="popup" style="display: none; border: #000000 1px solid; width: 300px;">
</div>
<br /><br />Here :)