Results 1 to 4 of 4

Thread: Forcing focus on anchor for Switch Content script

  1. #1
    Join Date
    Sep 2008
    Location
    Atlanta, GA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Forcing focus on anchor for Switch Content script

    1) Script Title: Switch Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tchcontent.htm

    3) Describe problem: I am using Switch Content here for articles: http://ca.homeownertrends.com/timhemm/articles-maintenance.php

    The issue is that when an article is opened by tapping on the TOP article preview (using Switch Content), the LOWER article preview (for the next article in sequence) opens to the bottom of that article ~ in other words, the LOWER article block opens at the end of the article.

    I need to integrate an anchor that will focus the Switch Content script to jump back to the top of the article similar to what was implemented here (using Dynamic Ajax script): http://ca.homeownertrends.com/timhemm/feature-homescreen_instructions.php

    The Dynamic Ajax script uses 'a href' in the inline JavaScript, so I could make it work there, but the Switch Content script does not use 'a href'. Here is a block of code from the article page. You can see how Switch Content is applied.....


    Code:
    <div id="article3-title" class="iconspan handcursor">
    	<div class="articleHeader-block">
    		<div class="articleHeader-position">
    		<header class="articleHeader">
    		<img src="http://aaaa.homeownertrends.com/content/symlink-articles/maintenance/when-your-freezer-stops-working/when-your-freezer-stops-working.png" class="articleHeader-image" />
    
    		When Your Freezer Stops Working
    		<p class="articleHeader-description">
    		Step-by-step instructions to help you preserve and managed food in your freezer when it breaks (or if you need to unplug it for a period of time).
    		</p>
    		</header>
    		</div>	
    			<div id="article3" class="articlegroup1">
    				<?php include("symlink-articles/maintenance/when-your-freezer-stops-working/when-your-freezer-stops-working.php"); ?>
    			</div>
    	</div>
    </div>

    Thank you for any assistance you can provide.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    You can programmically get the expanded header to be scrolled into view after it's clicked on by adding the code in red to the existing code inside the .js file:

    Code:
    this.togglestatus(header, this.statusOpen)
    	this.togglecolor(header, this.colorOpen)
    	setTimeout(function(){
    		if (header.scrollIntoView)
    			header.scrollIntoView()
    	}, 100)
    DD Admin

  3. #3
    Join Date
    Sep 2008
    Location
    Atlanta, GA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I inserted the script in the .js file with the other 'togglecolor' scripts. All that happened is that the articles remained expanded and would not collapse. Upon clicking the article titles, nothing happens thereafter. What am I doing wrong?

    Here is my application:


    Code:
    //JUMP TO TOP OF ARTICLE UPON CLICK/TAP <<<<<<<<<<<<<<<
    
    this.togglestatus(header, this.statusOpen)
    	this.togglecolor(header, this.colorOpen)
    	setTimeout(function(){
    		if (header.scrollIntoView)
    			header.scrollIntoView()
    }, 100)
    	
    	
    //PRIVATE: Sets color of switch header.
    
    switchcontent.prototype.togglecolor=function(header, status){
    	if (typeof this.colorOpen!="undefined")
    		header.style.color=status
    }
    
    
    //PRIVATE: Sets status indicator HTML of switch header.
    
    switchcontent.prototype.togglestatus=function(header, status){
    	if (typeof this.statusOpen!="undefined")
    		header.firstChild.innerHTML=status
    }

  4. #4
    Join Date
    Sep 2008
    Location
    Atlanta, GA
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry...I totally misread your instructions. After I did what you said, it worked!

    Thanks so much!

Similar Threads

  1. Forcing Focus on Radio Button
    By marain in forum JavaScript
    Replies: 1
    Last Post: 04-22-2013, 01:38 AM
  2. Switch Content script - swap anchor image when selected
    By katebellami in forum Looking for such a script or service
    Replies: 8
    Last Post: 06-07-2012, 12:16 PM
  3. Resolved Color of anchor link when focus is on menu - AnyLinkMenu
    By kanjigirl in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 09-22-2011, 04:53 PM
  4. Forcing in focus
    By cyberdreamer in forum JavaScript
    Replies: 5
    Last Post: 09-27-2008, 11:18 PM
  5. Switch Content Script and focus();
    By unintelligible in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 08-05-2005, 08:30 PM

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
  •