Pagina 1 din 1
eroare tab
Scris: Mie Mar 04, 2015
de andras
Salut,
S-a mai confruntat cineva cu problema asta? Am o pagina cu 2 tab-uri. Pe local merge normal, se deschide primul tab, dar pe server se deschide primul tab pentru scurt timp dupa care dispare si nu mai pot deschide nici un tab. Care sa fie cauza? Pe server este exact aceeasi copie de proiect ca pe local. Multumesc.
eroare tab
Scris: Mie Mar 04, 2015
de MarPlo
Salut
Daca acele tab-uri sunt facute cu javascript, verifica in Consola (F12) daca sunt erori si incearca sa le corectezi.
eroare tab
Scris: Mie Mar 04, 2015
de andras
Recunosc, partea asta inca n-am reusit s-o invat. La erori imi apare cam asa:
Cod: Selectaţi tot
Uncaught TypeError: Cannot read property 'length' of undefined
vinzari.php:353 Uncaught SyntaxError: Unexpected token }
vinzari.php:18312 Uncaught TypeError: Cannot read property 'removeAttribute' of null
Nu stiu sa le interpretez, dar la ultima eroare am:
Cod: Selectaţi tot
<script>
function tabsCnt(nr_tabs, av_tab) {
// cred ca eroarea se localizeaza aici:
document.getElementById('tabs').querySelector('.tabvi').removeAttribute('class');
// cred ca aici (mai sus) este problema
if (document.getElementById(av_tab))
document.getElementById(av_tab).setAttribute('class', 'tabvi');
for (var i = 0; i < nr_tabs; i++)
document.getElementById('tb' + i + '_c').style.display = 'none';
if (document.getElementById(av_tab + '_c'))
document.getElementById(av_tab + '_c').style.display = 'block';
}
// get the tabs elements
var ultabs = document.getElementById('tabs').querySelectorAll('li');
var nr_ultabs = ultabs.length;
// See if we have an activetab value (this will only happen if the page is refreshed)
if (sessionStorage.getItem('activetab')) {
tabsCnt(nr_ultabs, sessionStorage.getItem('activetab'));
}
// registers click for tabs
for (var i = 0; i < nr_ultabs; i++)
ultabs[i].addEventListener('click', function() {
tabsCnt(nr_ultabs, this.id);
// stores the id of the current active tab
sessionStorage.setItem('activetab', this.id);
}, false);
</script>
eroare tab
Scris: Mie Mar 04, 2015
de MarPlo
Incearca scriul asa, adaugat la sfarsitul paginii html, inainte de </body>.
Cod: Selectaţi tot
<script>
var el_tabs = document.getElementById('tabs');
function tabsCnt(nr_tabs, av_tab) {
if(el_tabs) {
if(el_tabs.querySelector('.tabvi')) el_tabs.querySelector('.tabvi').removeAttribute('class');
}
if(document.getElementById(av_tab)) document.getElementById(av_tab).setAttribute('class', 'tabvi');
for(var i = 0; i < nr_tabs; i++) document.getElementById('tb' + i + '_c').style.display = 'none';
if(document.getElementById(av_tab + '_c')) document.getElementById(av_tab + '_c').style.display = 'block';
}
// get the tabs elements
if(el_tabs.querySelectorAll('li')) {
var ultabs = el_tabs.querySelectorAll('li');
var nr_ultabs = ultabs.length;
// See if we have an activetab value (this will only happen if the page is refreshed)
if(sessionStorage.getItem('activetab')) {
tabsCnt(nr_ultabs, sessionStorage.getItem('activetab'));
}
// registers click for tabs
for(var i = 0; i < nr_ultabs; i++)
ultabs[i].addEventListener('click', function() {
tabsCnt(nr_ultabs, this.id);
// stores the id of the current active tab
sessionStorage.setItem('activetab', this.id);
}, false);
}
</script>
- Daca ai si alte script-uri in pagina, problema poate fi si de la erorile lor.
eroare tab
Scris: Mie Mar 04, 2015
de andras
Acum functioneaza corect. Multumesc mult, MarPlo !