Click here to Skip to main content
16,013,642 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I am working with an E-learning website.Here we have two frames .In a page on left side there is loading all TOC(Title,chapter1,chapter2---Index,Biblography--) on right side the content will display according to the TOC.The function is working perfectly

Here I want to do is when we change the Toc(Eg. chapterI to ChapterV)the scroll position also change according to that.
we can pass the value both 'chapter I' and 'chapter V' also we don' want the function like the following one
document.getElementById("frame_left").src = Url + "#" + passingvalue


Here is our code for loding the content in left frame
----------------
JavaScript
var content = jsonCommon.GetTocHtml_Stream(sBookID, SessionID)//getting the content;
                   globalcontent = content;
                   var s = document.getElementById('frame_left');
                   s.contentDocument.write(_globalcontent );

-------------------------
Here I got some hint
JavaScript
myIframe.contentWindow.scrollTo(xcord, ycord)//chapter I to chapterV;

how can I get the xcord and ycord or any other method?

Pls help me how can I implement this?


Thanks & regards,
soumya
Posted
Updated 9-Jan-12 7:14am
v2

Hi,
Thanks for your response
when I come to the following step it's showing one error
Point is not defined

var pt = new Point(0, 0);


pls help
VB
Thanks & regards,
soumya
 
Share this answer
 
Comments
Mehdi Gholam 10-Jan-12 6:34am    
Please use the comments for further assistance, do not post solutions.
there is a way to find x and y of a element

JavaScript
var thepoint  = myfunc_GetXY(myIframe.contentWindow.document.getElementById("some_Element"));
myIframe.contentWindow.scrollTo(thepoint.x, thepoint.y)//chapter I to chapterV;

or use : 
myIframe.contentWindow.document.getElementById("some_Element").scrollIntoWiew()

function myfunc_GetXY(aTag)
{
    var oTmp = aTag;
    var pt = new Point(0, 0);
    do
    {
        pt.x += oTmp.offsetLeft;
        pt.y += oTmp.offsetTop;
        oTmp = oTmp.offsetParent;
    } while (oTmp && oTmp.tagName != "HTML" && oTmp.tagName != "BODY");
    return pt;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900