sábado, 21 de janeiro de 2012

[Tutorial] Create spoilers in Blogger

This is for you folks who host your blogs on blogger and have blogspot.com in your blog URL. It requires a little more work and is a bit complicated so listen up.

Part 1 :Editing the Theme

First of all, go to your Dashboard >> Template >> Edit HTML

Then look for this line: ]]></b:skin> and </head> . There are two parts of codes.

First part, insert this code BEFORE ]]></b:skin>

CODE

   .commenthidden {display:none;}
   .commentshown {display:inline;}


Then add this code AFTER ]]></b:skin> and BEFORE </head>

CODE

<script type="text/Javascript">

function togglecomments (postid) {

var whichpost = document.getElementById(postid);

if (whichpost.className=="commentshown") { whichpost.className="commenthidden"; } else { whichpost.className="commentshown"; }

} </script>


Your HTML coding should now look like this. Don't worry about the difference in the symbol " and " because it means the same thing. Example:
user posted image

Save settings. Thats one part done. Phew!

Part 2 : Creating spoilers in blog post

To add spoilers to your blog post, click Create A Post and click Edit Html (its on the top right next to �Compose�). Then add this bit of code:

CODE

<a aiotitle="click to expand" href="javascript:togglecomments('SPOILER_NAME')">Click me to read spoilers</a>

<div class="commenthidden" id="SPOILER_NAME">put your hidden text here</div>


You can change SPOILER_NAME to anything you want but make sure that they are both EXACTLY the same. The <a aiotitle> and <div> dont have to be close to each other, as long as they are in the same post and have the exact same name. It will work.

Good luck and I hope this tutorial helps!

EDIT:I changed the javascript code because there were some errors when you save the HTML. Make sure when you write your post its in EDIT HTML mode and not Compose mode

0 comentários:

Postar um comentário