Hi Holger,
Thanks again for your help! Really!
1. You mentioned that in the function documentLoaded, I could access
the currently loaded file with:
svgDoc = appContent.contentDocument
But I look through your zoomAndPan codes, there is another line
before this:
sdtsvgDocument=appContent.contentDocument
svgRoot=sdtsvgDocument.documentElement
I suppose the svgRoot is the same as the svgDoc above, am I right? If
so, then should I include this documentElement?
Below is the snippet of my code which I modified after your help:
*************************************************
window.addEventListener("load", mtOnWindowLoad, false);
document.addEventListener("mousemove", calculatePos, false);
document.addEventListener("click", reading, false);
function mtOnWindowLoad(){
appContent = window.document.getElementById("content");
if (appContent)
appContent.addEventListener("load", documentLoaded, true);
}
function documentLoaded(){
sdtsvgDocument = appContent.contentDocument;
svgDOM = sdtsvgDocument.documentElement;
var cType = sdtsvgDocument.contentType;
if (cType == "image/svg+xml") {
parseSVGFile(svgDOM);
} else {
alert("Not a SVG");
}
function parseSVGFile (svgDOM) {
var path = svgDOM.getElementsByTagName('path');
for (var z = 0; z < path.length; z++) {
if (path[z].getAttribute('id') == 'xAxis') {
var xAxis = path[z].getAttribute('d');
var txt = xAxis;
num = txt.split(" ")[1];
}
}
(...... all other codes.....)
}
function getMousePosition(event) {
var posX = 0;
var posY = 0;
posX = event.clientX + document.body.scrollLeft;
posY = event.clientY + document.body.scrollTop;
var position = new Array(2);
position[0] = posX;
position[1] = posY;
return position;
}
function calculatePos (event) {
var mousePosition = getMousePosition(event);
checkAreaIn(mousePosition);
}
function checkAreaIn(mousePosition) {
mx = mousePosition[0];
my = mousePosition[1];
var offsetX = 17;
var offsetY = 40;
var XCanva = canvaX + offsetX;
var X2Canva = canvaWidth + offsetX;
var YCanva = canvaY + offsetY;
var Y2Canva = canvaHeight + offsetY;
window.status = "X= " + mx + " Y= " + my;
if (mx > XCanva && mx < X2Canva && my > YCanva && my < Y2Canva) {
readAbtGraph();
} else {
}
}
(.... all other codes....)
}
***************************************************
2. As above, I used one of the
posX = event.clientX + document.body.scrollLeft
It is working before that, when I am reading svg file on a local
machine and I tried on a simple html file (Javascript embedded in
html) only with this code, it works as well. But why when I included
only this mouse position codes in overlay.js and place it in a plug
in, it doesn't work (nothing shown in status bar). But when I delete
the end part and left: posX=event.clientX, it works (mouse position
shown in status bar). DO you have any clue why this happen? Why
document.body.scrollLeft can't be used in this case?
3. Logically I think I understand how this will work. But there is
one question. If I wish to start my plugin only when the svg File is
displayed in a new page (such as when we right click and "view SVG"),
and not when a svg File embedded in a webpage. If you know what I
mean? Can this be done?
4. This might be a silly question: I suppose I need to uninstall the
firefox I have in my machine (firefox 1.0.6) before I install this
alpha version from the link you gave to me. Am I right?
5. Lastly, just for curiousity, why is this approach only works in
the version you mentioned, but not for the previous version?
I am really sorry if I ask too many questions. Hope you don't mind.
Really sorry and thanks a lot for your help.
S.
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hv77b2l/M=362131.6882499.7825260.1510227/D=groups/S=1706030389:TM/Y=YAHOO/EXP=1124277535/A=2889191/R=0/SIG=10r90krvo/*http://www.thebeehive.org
">Get Bzzzy! (real tools to help you find a job) Welcome to the Sweet Life
- brought to you by One Economy</a>.</font>
--------------------------------------------------------------------~->
-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my
membership"
----
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/svg-developers/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/