www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 10-24-2006, 01:33 PM
    salsera salsera is offline
    Registered User
     
    Join Date: Oct 2006
    Posts: 3
    showHide div from href - page jumps to div, need to load fully from top

    I am having trouble with the showHide function. I have one page (Pg1) that contains several divs which all showHide just perfectly. However, when I call the showHide function from one of the other pages (Pg2, Pg3, etc) using href, (Pg1) loads and the correct div requested shows, but the page loads in the browser with the content of that div at the top. I need this function to work so that the entire page is in view, but the text in the div requested simply shows in the appropriate cell on that page. I know most people are loving the jump features, but i don't want my page to jump, I need it to remain fully in view weather using the showHide function from within the same page, or calling it from an external link. Can anyone help? I've included code below for both working (within page) and malfunctioning (when calling from an externalpage)

    Thanks in advance


    malfunctioning (when calling from an externalpage)
    Code:
    <script type="text/javascript">
    
    function Show(What, CheckURL) 
    {
       var a, i;
    
       if (CheckURL) {
          i = document.URL.indexOf("#");
          if(i != -1) {
             Show(document.URL.substring(i+1,document.URL.length));
             return;
          }
       }
       if (!document.getElementsByTagName) 
          return;
       a = document.body.getElementsByTagName("div");
       if (a.length == 0) 
          return;
       if (typeof a[0].style != 'object') 
          return;
       if (typeof a[0].style.display == 'undefined') 
          return;
       for (i = 0; i < a.length; i++) {
          if (a[i].className != "section") 
             continue;
          if (a[i].id != What) 
             a[i].style.display = "none";
          else 
             a[i].style.display = "block";
      }
      return true;
    }
    </script>

    Then within the body:
    Code:
    <a href="javascript:parent.location.replace('javaswitch.html?showHide=#dd')";>
    I've also tried
    <a href="javaswitch.html"; onClick="Show('#dd')">
    which also works, but has the same malfunction.


    working (within page) showHide
    Code:
    <script type="text/javascript">
    
    function Show(What, CheckURL) 
    {
       var a, i;
    
       if (CheckURL) {
          i = document.URL.indexOf("#");
          if(i != -1) {
             Show(document.URL.substring(i+1,document.URL.length));
             return;
          }
       }
       if (!document.getElementsByTagName) 
          return;
       a = document.body.getElementsByTagName("div");
       if (a.length == 0) 
          return;
       if (typeof a[0].style != 'object') 
          return;
       if (typeof a[0].style.display == 'undefined') 
          return;
       for (i = 0; i < a.length; i++) {
          if (a[i].className != "section") 
             continue;
          if (a[i].id != What) 
             a[i].style.display = "none";
          else 
             a[i].style.display = "block";
      }
      return true;
    }
    </script>

    Then within the body:
    Code:
    <a href="javascript:showHide('#da')"; class="ms_leftnav" onClick="Show('da');">da title</a>
    I don't really understand why the code within the page is working and the code linking externally is not - any help is appreciated.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 03:15 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.