Я устраняю проблему с сайтом, который использует стиль вкладок, настроенный для раздела часто задаваемых вопросов в iframe. Функциональность вкладок очень проста и выглядит следующим образом:
function initcategory(catnum){
for(i=1;i<=catnum;i++){
var onC = "togglecat(" + i + ")";
document.getElementById('ch' + i).onclick = new Function(onC);
}
var anchor = document.location.href.split('#');
if(!isNaN(anchor[1])){
togglecat(anchor[1]);
document.getElementById('ch' + anchor[1]).scrollIntoView();
}
//sendtsize(100);
}
function togglecat(num){
var tmps = document.body.scrollHeight;
if(document.getElementById('c' + num).className == 'category'){
document.getElementById('c' + num).className = 'category-active';
tmps = tmps + document.getElementById('c' + num).scrollHeight;
} else {
tmps = tmps - document.getElementById('c' + num).scrollHeight;
document.getElementById('c' + num).className = 'category';
}
sendtsize(tmps - 50);
setTimeout(function() {
sendsize();
}, 50);
}
<div class="category" id="c1">
<div class="sectionheader" id="ch1">
<p>Basic Information</p>
<div class="plus"> </div>
</div>
<div>
<h3>What is This?</h3>
<p>This is an LLC that provides a service that enables account holders to do a thing by phone or mobile device.</p>
<h3>Is this legal?</h3>
<p>this is a legal, US-based, a service, licensed and regulated in many states. </p>
<h3>How much does it cost to join?</h3>
<p>There are no fees to enjoy basic this online and telephone services:</p>
<ul>
<li>No charge to open an account</li>
<li>No charge for certain types of deposits</li>
<li>No charge for certain methods of withdrawal</li>
<li>No surcharges</li>
<li>No membership fees</li>
<li>No charge for basic audio/video services</li>
</ul>
<p>Some premium services do carry additional charges.</p>
<h3>What are your advantages?</h3>
<ul>
<li>Fast enrollment system gets you wagering in no time.</li>
<li>No fees. No membership, monthly or per-wager surcharges.</li>
<li>Direct deposit (some restrictions apply).</li>
<li>Funds can be withdrawn online, by phone or in person.</li>
<li>Secure and safe </li>
<li>Legal, licensed and based in the United States.</li>
</ul>
</div>
</div>
Вкладки отлично работают на отдельной странице, а код позволяет веб-мастеру добавлять дополнительные вкладки в HTML без изменения каких-либо сценарий как есть. Проблема, с которой мы сталкиваемся, заключается в том, что при открытии вкладки страница привязывается к верхней части страницы. Это неудобно для конечного пользователя, и я не могу найти решение. Любые изменения, которые я внес в сценарий, не меняют поведения внутри iframe. Любое понимание здесь будет оценено.