SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Nov 2002
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help to hide/show div's in a frame

    Just when I thought I had it licked!

    Anyway, I have a group of functions that all work about the same, "back_page(this)", "fore_page(this)", ...etc. They work to bring the requested div in and out of the frame. But one thing I would like to add is to beable to hide the previous and show the requested div.

    here is my code so far:
    Code:
    function back_page(elem)
    {
    		elem.page=document.forms['chapage'].elements['pge'];
    		elem.chapt=document.forms['chapage'].elements['chp'];
    		elem.pgid='Pg'+eval(elem.page.value);
    		elem.newchapt=frames['there'].document.getElementById(elem.pgid).getAttribute('valueC');
    		elem.newpage=frames['there'].document.getElementById(elem.pgid).getAttribute('valueD');
    		elem.chapt.value=elem.newchapt;
    		elem.page.value=elem.newpage;
    		frames['there'].location.href=elem.chapt.value+'.html#Pg'+elem.page.value;
    		
    		elem.newpgid='Pg'+elem.newpage;		
    		MM_showHideLayers(elem.pgid,'','hide',elem.newpgid,'','show');
    		
    }
    The problem is that the show/hide function (from dreamweaver) doesn't have the link to the frame. how do I do this. I have tried a bunch of stuff, but just seem to make things worse.

    -berzerko

  2. #2
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    A BIG NO NO to hidden objects.....

    Google really doesn't like hidden content as the method is also used by spammers of Search Engines. So I advise you not to use it, unless you don't mind your site being banned from the index.

    And I speak from experience
    I used it on my site, this month I was dropped from SE's index.

    I advise you to put all your divs into 1 long scrolling div and bring the relevent one into view by using the focus() command. This is a better method if all your divs can go into one place, as viewers with JS off can also view it.

    Check my homepage link below to see it working.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  3. #3
    SitePoint Addict
    Join Date
    Nov 2002
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am closer, but the problem seems to be that the code overwrites itself (elem.pgid) and rehides the div.

    here is the code:
    Code:
    function back_page(elem)
    {
    		elem.page=document.forms['chapage'].elements['pge'];
    		elem.chapt=document.forms['chapage'].elements['chp'];
    		elem.oldchapt= elem.chapt.value;
    		elem.pgid='Pg'+eval(elem.page.value);
    		elem.newchapt=frames['there'].document.getElementById(elem.pgid).getAttribute('valueC');
    		elem.newpage=frames['there'].document.getElementById(elem.pgid).getAttribute('valueD');
    		elem.chapt.value=elem.newchapt;
    		elem.page.value=elem.newpage;
    		
    		if (elem.oldchapt != elem.newchapt)
    	{
    		frames['there'].location.href=elem.chapt.value+'.html#Pg'+elem.page.value;
    		hideObj(elem.pgid);
    		showObj(elem.newpgid);
    	} else {
    		hideObj(elem.pgid);
    		showObj(elem.newpgid);
    	}	
    							
    }
    function hideObj(objid)
    {
    	parent.frames['there'].document.getElementById(objid).style.visibility ='hidden';
    }
    function showObj(objid)
    {
    	parent.frames['there'].document.getElementById(objid).style.visibility ='visible';
    }

  4. #4
    SitePoint Addict
    Join Date
    Nov 2002
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Markdidj ,

    The focus() doesn't seem to work for me. I could just as well chang the zindex as I could hide. The method is the same, but it still doesn't work! why?

    -berzerko

  5. #5
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Sorry, just had a better look at the first message. What I did was to set up a previous div and call it main, which is the main div onload.
    prevdiv="main"
    function hideandshow(nextdiv) {
    function to hide prevdiv
    function to show nextdiv
    prevdiv=nextdiv }

    this stops the need of onmouseouts as well.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  6. #6
    SitePoint Addict
    Join Date
    Nov 2002
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I must be slow, I still don't get it. Ive been trying everything I can think of, but have not gotten very far.

    -berzerko


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
  •