View Full Version : Spoiler tag without javascript?
pjkcards
02-13-2015, 12:51 AM
A few users have said the spoiler tag isn't working, and I suspect it is because their phone doesn't allow it. Is it possible to do it without javascript? Or what is the best way to handle this issue?
Right now this is what we're using:
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px"><b>Spoiler</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('d iv')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('d iv')[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;">
{param}
</div>
</div>
</div>
Thanks.
OUTL4W
02-13-2015, 06:53 AM
I'm sure you'll see many different variations for this but here's what I use
<div style="margin:20px; margin-top:5px">
<div class="smallfont" style="margin-bottom:2px; width:852; height:26"><right><font color="red"><b> </b></font></right>
<input type="button" value="Spoiler" style="font-size:10px;margin:0px;padding:0px;" onClick="if (this.parentNode.parentNode.getElementsByTagName(' div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('d iv')[1].getElementsByTagName('div')[0].style.display = ''; this.innerText = ''; this.value = 'Hide'; } else { this.parentNode.parentNode.getElementsByTagName('d iv')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'Spoiler'; }">
</div>
<div>
<div style="display: none;">
{param}
</div>
</div>
</div>
Works just fine on mobile....
Edit: didn't look at the entire code but it looks exact same almost but I have no issues on either vb3 or vb4 forum on mobile.
It's not possible to do this without JavaScript, it needs to catch the onclick event on the button so it can then open/close the div with the content.
pjkcards
02-13-2015, 03:46 PM
Thanks for the replies. For anyone using a spoiler, have you ever had any complaints about people who click and nothing happens? I suspect it is due to their browser not allowing javascript. Is this the case?
It's highly unlikely that someone has JavaScript disabled. JavaScript is enabled on pretty much all desktop and mobile browsers nowadays, unless they manually disabled it in the settings.
OUTL4W
02-14-2015, 08:20 AM
Thanks for the replies. For anyone using a spoiler, have you ever had any complaints about people who click and nothing happens? I suspect it is due to their browser not allowing javascript. Is this the case?
Guess it all depends what they were trying to show. If it was flash related then it would show as blank image. Only certain mobile web browser's will show flash content.
pjkcards
03-10-2015, 05:07 PM
Looks like it is the mobile theme disabling it.
When using the desktop version the spoilers work fine. When using mobile the mobile theme, it doesn't. What's the quickest way to solve this issue? Thanks.
I don't really understand what's going on there, but it seems like in the mobile style, the big area that say "Show" is not the thing that needs to be clicked to show it. There's another <input> tag that's not showing up at all.
pjkcards
03-10-2015, 07:10 PM
I don't really understand what's going on there, but it seems like in the mobile style, the big area that say "Show" is not the thing that needs to be clicked to show it. There's another <input> tag that's not showing up at all.
The example posted is 3 different kinds of spoiler tags, including the one I posted above, and the one Outl4w posted. What is the best way to resolve this? No idea why when clicked the input doesn't show. Thanks.
pjkcards
03-19-2015, 04:10 AM
bump, thanks.
Black Snow
03-22-2015, 05:03 PM
Try this: http://codepen.io/AngelKrak/pen/FojxE
OUTL4W
03-27-2015, 12:24 PM
Try this: http://codepen.io/AngelKrak/pen/FojxE
its a lil wonky but I did find this...
replacement:
<input class="spoilerbutton" type="button" value="Show" onclick="this.value=this.value=='Show'?'Hide':'Show';">
<div class="spoiler"><div>
{param}
</div></div>
additional.css:
.spoilerbutton {
display:block;
margin:5px 0;
}
.spoiler {
overflow:hidden;
background: transparent;
}
.spoiler > div {
-webkit-transition: all 0.75s ease;
-moz-transition: margin 0.75s ease;
-o-transition: all 0.75s ease;
transition: margin 0.75s ease;
}
.spoilerbutton[value="Show"] + .spoiler > div {
margin-top:-100%;
}
.spoilerbutton[value="Hide"] + .spoiler {
padding:5px;
}
change the items in red to your preference....
pjkcards
04-22-2015, 03:09 PM
Thanks for the replies, but still not working. This is the result of the original, the one Black Snow recommended, and the last one is OutL4w:
http://i.imgur.com/nVkQ2Yv.png
Perhaps the theme is somehow messing with the show/hide. What's the best way to troubleshoot this?
Thanks.
pjkcards
06-01-2015, 03:12 AM
Bump. Just got a new mobile theme going and the Show button still does nothing. Anyone have a spoiler working on mobile themes?
Thanks.
pjkcards
08-24-2015, 12:35 AM
Still haven't been able to get this to work, see screenshot here:
http://i.imgur.com/nVkQ2Yv.png
Just tried this one too with the same result:
https://vborg.vbsupport.ru/showthread.php?t=289968
Any ideas to get a spolier working on mobile would be appreciated, thanks.
pjkcards
09-07-2015, 12:46 AM
Edit: Problem solved. This works on mobile:
https://vborg.vbsupport.ru/showthread.php?t=279069
I modified it a bit for the option tag, and to make all content 80% width. But if you're having issue with the spoiler on mobile, the above will work. Thanks guys, hope that helps.
akz645
09-08-2015, 03:52 PM
Edit: Problem solved. This works on mobile:
Replacement:
<div style="margin: 5px 20px 20px;">
<div style="smallfont" style="margin: 0px; padding: 0px; width: 45px; font-size: 10px;"> <b>Spoiler:</b> <spa
onclick="if (this.parentNode.parentNode.getElementsByTagName(' div')[1].getElementsByTagName('div')[0].style.display != '')
{ this.parentNode.parentNode.getElementsByTagName('d iv')[1].getElementsByTagName('div')[0].style.display = '';
this.innerHTML = '<a href=\'#\' onClick=\'return false;\'>Hide</a>'; }
else { this.parentNode.parentNode.getElementsByTagName('d iv')[1].getElementsByTagName('div')[0].style.display = 'none';
this.innerHTML = '<a href=\'#\' onClick=\'return false;\'>Show</a>'; }" /><a href="#" onClick="return false;">Show</a></span>
</div><div class="alt2" style="border: 1px inset ; margin: 0px; padding: 6px;">
<div style="display: none;">
{param}
</div></div></div>
That one I personally made work.
I had to change a couple of things, until I finally got it to work. I tried to make it resemble the classic spoiler button (https://vborg.vbsupport.ru/showpost.php?p=2537228&postcount=1).
<input type="button"
I think it's the 'button' feature that makes it not work on the mobile skin.
Every single spoiler that I've seen which uses button, doesn't work on the mobile skin.
Thanks for the replies. For anyone using a spoiler, have you ever had any complaints about people who click and nothing happens? I suspect it is due to their browser not allowing javascript. Is this the case?
The best way to test, is by going to the mobile skin from your PC and then trying yourself.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.