PDA

View Full Version : DHTML Window Widget Named Anchor Issue



crabine
01-07-2009, 07:28 PM
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)?

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!

ddadmin
01-08-2009, 10:15 AM
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()?

crabine
01-08-2009, 03:40 PM
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().

ddadmin
01-10-2009, 08:02 AM
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:


<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:


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)

crabine
01-12-2009, 04:55 PM
Thanks!