Results 1 to 5 of 5

Thread: DHTML Window Widget Named Anchor Issue

  1. #1
    Join Date
    Jan 2009
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question DHTML Window Widget Named Anchor Issue

    1) Script Title:
    DHTML Window Widget

    2) Script URL (on DD):
    http://dynamicdrive.com/dynamicindex8/dhtmlwindow/

    3) Describe problem:
    For ajax content, is there a way to jump to a named anchor in the window (example below does not work)?
    Code:
    dhtmlwindow.open("ajaxbox", "ajax", "windowfiles/external.htm#anchor1", "#3: Ajax Win Title", "width=450px,height=300px,left=300px,top=100px,resize=1,scrolling=1")
    Thanks for your help!

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

    Default

    Just to clarify, are you saying your DHTML window contains an Ajax fetched page with vertical scrollbars, and you need a way to scroll to a particular position within that page automatically upon calling dhtmlwindow.open()?
    DD Admin

  3. #3
    Join Date
    Jan 2009
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by ddadmin View Post
    Just to clarify, are you saying your DHTML window contains an Ajax fetched page with vertical scrollbars, and you need a way to scroll to a particular position within that page automatically upon calling dhtmlwindow.open()?
    Yes, that's correct. I want to scroll to the named anchor within that page, when calling dhtmlwindow.open().

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

    Default

    There's no "quick" way to do this. One rather inelegant way is to first identify the element within the Ajax page you wish to scroll to using a ID attribute, for example:

    Code:
    <div>
    <img src="windowfiles/bird.jpg" style="float: left; margin: 0 10px 10px 0" />Birds are bipedal, warm-blooded, oviparous vertebrate animals characterized primarily by feathers, forelimbs modified as wings, and hollow bones.
    
    <p>Birds are bipedal, warm-blooded, oviparous vertebrate animals characterized primarily by feathers, forelimbs modified as wings, and hollow bones.
    
    <p>Birds are bipedal, warm-blooded, oviparous vertebrate animals characterized primarily by feathers, forelimbs modified as wings, and hollow bones.
    
    <p>Birds are bipedal, warm-blooded, oviparous vertebrate animals characterized primarily by feathers, forelimbs modified as wings, and hollow bones.
    
    <p id="targetpoint">Birds are bipedal, warm-blooded, oviparous vertebrate animals characterized primarily by feathers, forelimbs modified as wings, and hollow bones.
    
    <p>Birds are bipedal, warm-blooded, oviparous vertebrate animals characterized primarily by feathers, forelimbs modified as wings, and hollow bones.
    </div>
    Then on your main page when you call dhtmlwindow.open(), follow that code with the code in red that periodically scans the page to see when that element has been added to the page, then scrolls to it:

    Code:
    ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "windowfiles/external.htm", "#3: Ajax Win Title", "width=450px,height=300px,left=300px,top=100px,resize=1,scrolling=1")
    scrolltimer=setInterval(function(){
    	try{
    		if (document.getElementById("targetpoint")){
    			document.getElementById("targetpoint").scrollIntoView()
    			clearInterval(scrolltimer)
    		}
    	} catch(e){
    		clearInterval(scrolltimer)
    	}
    	}, 100)
    DD Admin

  5. The Following User Says Thank You to ddadmin For This Useful Post:

    crabine (01-12-2009)

  6. #5
    Join Date
    Jan 2009
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks!

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
  •