Search code examples
javascripthtmlbbcodephpbb

BBCode spoiler with BBCodes in the label


Okay, let me explain what kind of "spoiler tag" I mean:
In a phpBB forum I'm on, there is a [spoiler] BBCode that hides the text inside, with a button to show/hide, that is supposed to look like the prosilver submit/preview buttons in the posting page. It's been done pretty well with an <input> element (actually I believe <input type="submit" value="Show Spoiler"> with an onclick attribute), but of course now we're looking for a way of implementing a similar one except with a custom label on the button—including using further BBCodes inside of it. Needless to say, it's difficult to do this without creating an XSS risk.


Solution

  • Try using the <button> tag instead of the <input> tag. It has more capabilities than the <input> tag, and can have other elements in it, like this: <button type="button">The third <span style="color:red">word</span> on this button is red.</button>