Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Spoilers in a basic webpage?

Simple question.

Can I do spoilers, or something like spoilers in basic HTML or PHP?


and can i make it so that it doesn't process what's in the spoiler til after it's opened?
 
You can't do it with strictly HTML or PHP; you will need CSS and JavaScript (it's feasible with just JavaScript, but I recommend the CSS+JS route). I suppose it's possible to make it not process that until after and just insert the stuff by traversing the DOM or using innerHTML... but it depends what the contents are.

If it contains just text, just having the stuff in the script tag is "processing" it anyway, so the only way I can think to make it delay the processing is by using the PHP to store some sort of temporary file, then accessing that file with an XmlHttpRequest. Pretty undesirable. But if it's just text, unless it's an entire book, processing it on page load is probably not bad.
 
Basically, look in the sourcecode of your favourite forum.

A few pointers:

<div class="spoiler">
..<button onclick="javascript:spoiler(this.parentNode)"/>
..<div class="spoiler_inner">
....content
..</div>
</div>

spoiler_inner css: visible:none;
button javascript: spoiler method, should set the 'visible' css tag to 'visible' or something, if 'none', and to 'none' or something if 'visible'.

Try looking in the source of this forum and search for the function 'spoiler(header)'... if that's allowed :p
 
I got it! And yes, I looked at the source of this very page. Two/Three little functions that make a spoiler work, eh?

And AmIMeYet, this is off-topic, but I was looking at your sig, and methods from the Kernel module don't need Kernel. Require is just 'require "file.rb"; '. And another way to do requires in RMXP/VX is to do :

file = File.open('file.rb', 'rb');
eval(file.read);
</off-topic>
 
Ok, glad you found it.
Yeah.. weird they use so many functions.. :S
I would think they could do with just 1.

<off-topic>
No, the kernel prefix in this case is required, but that's only because RGSS is so.. .. .. 'special'.
Require's should just work in the first place.
And yes, eval() would work, but it's better to let scripts that actually use require work that way.
</off-topic>
 
Okay, now maybe I can work on other cool little trinkets for my website...

But might I ask, how did you get the button(to open/close the spoiler) to stay on the right side of the post? Mine puts the button right next to my text in the <span> tags.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top