Skip to content

Спойлер

В общем такой вопрос. Есть код спойлер все прекрасно работает. Но мне нужно чтобы вместо слова спойлер можно было свое название вводить, как это сделать не хватает сил(.

Вот код: и извините если не туда

<script language='JavaScript' type="text/javascript">
<!--

function getPostObj(id) {
itm = null;
if (document.getElementById) {
 itm = document.getElementById(id);
}
else if (document.all) {
 itm = document.all[id];
}
else if (document.layers) {
 itm = document.layers[id];
}
return itm;
}

function layer(layer_id) {
 var full_head = "Скрыть";
 var short_head = "Показать";
 var id = document.getElementById("layer_" + layer_id);
 var head = document.getElementById("a_layer_" + layer_id);
 if (id.style.display == "none") {
  head.innerHTML = " <img src=\"http://ipb.su/uploads/rolevoysu/web/post-1-1428930084.gif\" border=\"0\" /> " + full_head;
  id.style.display = "";
 }
 else {
  head.innerHTML = " <img src=\"http://ipb.su/uploads/rolevoysu/web/post-1-1428930077.gif\" border=\"0\" /> " + short_head;
  id.style.display = "none";
 }
}
 function changePost(id, author) {
 var PostValue = getPostObj(id).innerHTML;

 // Спойлер
 var date = new Date();
 while(PostValue.indexOf("[sP]")!=-1 && PostValue.indexOf("[/sP]")!=-1 ) {
 if (PostValue.indexOf("[sP]") > PostValue.indexOf("[/sP]")) {
PostValue = PostValue.replace("[/sP]","[плохой тег]");
 } else {
var i = date.getTime() + "" + Math.round(Math.random() * 100) + 1;
PostValue = PostValue.replace("[sP]", '<div class="sp-wrap" id="a_layer_' + i + '" onclick="layer(\'' + i + '\'); return false;"> <img src="http://ipb.su/uploads/rolevoysu/web/post-1-1428930077.gif" border="0" /> Показать</div><div class="sp-body"id="layer_' + i + '" style="display: none"><div></div>');
PostValue = PostValue.replace("[/sP]", "</div>");
 }
 }

// другие теги 

  // выводим конечный результат
  getPostObj(id).innerHTML = PostValue;
}

//-->
</script>

Featured Replies

а где это слово "спойлер" у вас задействовано? в коде его нет

  • Author
а где это слово "спойлер" у вас задействовано? в коде его нет

 

там вместо спойлер идет [sP][/sP]

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.