SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jul 2012
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by aidoru View Post
    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?
    Here is the code that you are using for both the bio and the portfolio sections:

    Code javascript:
    $('#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.

    Code javascript:
    $('#divMain2').toggle('slow', function() {
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Jul 2012
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Paul, thanks for your answer... I don't think the selector in the portfolio area could the cause of the problem.

    Code:
    #divMain2
    and
    Code:
    #box
    have different coordinates and different use in this code

    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


    Code:
    $(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();
    });
    });

  4. #4
    SitePoint Evangelist silver trophybronze trophy
    Join Date
    Jul 2013
    Posts
    406
    Mentioned
    22 Post(s)
    Tagged
    0 Thread(s)
    Hi aidoru,
    I guess not the javascript is the culprit, but the content of the giovannicaccamo.eu/html/policy.html 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.

    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 giovannicaccamo.eu/html/bio.html "page", where it is already done: <!-- edited (removed headers) -->

    And maybe also the html-errors (26 Errors, 4 warnings) play a role. Never wrong to have valid html.

    The 5 css-errors in the giovannicaccamo.eu/script/caccamostylesheet.css will have no influence on the toggle thingy, but: never wrong to have valid css.

  5. #5
    SitePoint Member
    Join Date
    Jul 2012
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •