Toggle wrong behavior

Hi to everyone
I’ve got a wrong behavior when I try to use a toggle button in this site: www.giovannicaccamo.eu
The toggle button is on footer and it is “Privacy Policy” div.
It use the same jquery code used for the “Bio” div and they work fine on my pc but online I have got a strange behavior.
Any idea?
I remember I’m a beginner…
Thanks

Paco Toscano

Here is the code that you are using for both the bio and the portfolio sections:


$('#bio').click(function() {
  $('#divMain2').toggle('slow', function() {
    //qui possiamo far eseguire altre funzioni correlate
	$('.scroll').mCustomScrollbar(); //edited
  });
});

$('#portfolio').click(function() {
  $('#box').toggle('slow', function() {
    //qui possiamo far eseguire altre funzioni correlate
	
  });
});

It seems that the selector in the portfolio area is the cause of the problem. Changing #box to #divMain2 should result in an improvement there for you.


$('#divMain2').toggle('slow', function() {

Hi Paul, thanks for your answer… I don’t think the selector in the portfolio area could the cause of the problem.

#divMain2

and

#box

have different coordinates and different use in this code

#box {  display:none;}

because it contains portfolio submenus.

The problem is on #footb in the footer that give you access to privacy policy information

this is the whole query in the script.js file

$(document).ready(function(){

$('#mailme').click(function() {
  $('#contact').toggle('slow', function() {
    //qui possiamo far eseguire altre funzioni correlate
  });
});

$('#bio').click(function() {
  $('#divMain2').toggle('slow', function() {
    //qui possiamo far eseguire altre funzioni correlate
	$('.scroll').mCustomScrollbar(); //edited
  });
});

$('#portfolio').click(function() {
  $('#box').toggle('slow', function() {
    //qui possiamo far eseguire altre funzioni correlate
	
  });
});

$('#footb').click(function() {
  $('#divMain2').toggle('slow', function() {
    //qui possiamo far eseguire altre funzioni correlate
	
  });
});

$('#bio a').click(function(e) {
    var url = $(this).attr('href') 
   $('#divMain2').html('loading...').load(url,function(){
		$('.scroll').mCustomScrollbar('update'); //edited
   }); 
   e.preventDefault();
});

$('#footb a').click(function(e) {
    var url = $(this).attr('href') 
   $('#divMain2').html('loading...').load(url,function(){
		$('.scroll').mCustomScrollbar('update'); //edited
   }); 
   e.preventDefault();
});
});

Hi aidoru,
I guess not the javascript is the culprit, but the content of the [U]giovannicaccamo.eu/html/policy.html[/U] page.

  • This “page” is set up as a complete real html-page, with the <html><head></head><body></body></html> construction.
  • But in fact it should be only a code fragment, which is directly inserted by the javascript in the html-code of the main page (which has already the <html><head><body>).
  • What happens: via the <head> in the policy.html not only the stylesheet is loaded for the 2nd time but also the script.js for the 2nd time (which commands the toggle function: again)! > Confusion for the browsers. :wink:

So I think the problem can be solved by removing everything besides the <div id=“divPolicy”>… and what’s in it … </div>.

Just as the [U]giovannicaccamo.eu/html/bio.html[/U] “page”, where it is already done: <!-- edited (removed headers) –>

And maybe also the html-errors ([U]26 Errors, 4 warnings[/U]) play a role. Never wrong to have valid html. :slight_smile:

The [U]5 css-errors[/U] in the [URL=“http://www.giovannicaccamo.eu/script/caccamostylesheet.css”][U]giovannicaccamo.eu/script/caccamostylesheet.css[/U] will have no influence on the toggle thingy, but: never wrong to have valid css. :slight_smile:

Hi Francky thanks a lot. Your suggestions were right.
I’ve solved modifying the policy.html erasing the <head> section.
Now I’ll check all the code errors with html and css validator and I’ll try to fix them.
I’m trying to learn by building noprofit (for me) web sites for friends…

Thanks again

Paco Toscano