THY02K
May 7th, 2009, 10:28 PM
hello
I need to determine from within an iframe mouse click "location", by that I mean:
1. nPosition = # characters from start of HTML document (err... preferably start means first character of hTML doc in iframe) to first character of the selected text.
This gives you x/y position, which is not what we need ...
Browser = navigator.appName
Net = Browser.indexOf("Netscape")
Micro = Browser.indexOf("Microsoft")
Netscape = false
IE = false
if(Net >= 0) {
Netscape = true
}
if(Micro >= 0) {
IE = true
}
function XYpos() {
if (IE == true) {
xPos = event.screenX
yPos = event.screenY
alert(xPos + " left " + yPos + " down")
}
else if (Netscape == true) {
alert("Script won't work: " + "\n" + "You're using Netscape")
}
This retrieves the selected text, but (a) not the position {nPosition, nLength} of selected text and (b) not friendly with iframe.
function getSelText()
{
var txt = '';
if (window.getSelection)
{
txt = window.getSelection();
}
else if (document.getSelection)
{
txt = document.getSelection();
}
else if (document.selection)
{
txt = document.selection.createRange().text;
}
else return;
alert(txt);
}
From W3C doc (URL below), these information is available.
"mousedown
The mousedown event occurs when the pointing device button is pressed over an element. This event is valid for most elements.
* Bubbles: Yes
* Cancelable: Yes
* Context Info: screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, button, detail"
Any suggestion? Thanks.
REF: http://www.w3.org/TR/DOM-Level-2-Events/events.html[^]
I need to determine from within an iframe mouse click "location", by that I mean:
1. nPosition = # characters from start of HTML document (err... preferably start means first character of hTML doc in iframe) to first character of the selected text.
This gives you x/y position, which is not what we need ...
Browser = navigator.appName
Net = Browser.indexOf("Netscape")
Micro = Browser.indexOf("Microsoft")
Netscape = false
IE = false
if(Net >= 0) {
Netscape = true
}
if(Micro >= 0) {
IE = true
}
function XYpos() {
if (IE == true) {
xPos = event.screenX
yPos = event.screenY
alert(xPos + " left " + yPos + " down")
}
else if (Netscape == true) {
alert("Script won't work: " + "\n" + "You're using Netscape")
}
This retrieves the selected text, but (a) not the position {nPosition, nLength} of selected text and (b) not friendly with iframe.
function getSelText()
{
var txt = '';
if (window.getSelection)
{
txt = window.getSelection();
}
else if (document.getSelection)
{
txt = document.getSelection();
}
else if (document.selection)
{
txt = document.selection.createRange().text;
}
else return;
alert(txt);
}
From W3C doc (URL below), these information is available.
"mousedown
The mousedown event occurs when the pointing device button is pressed over an element. This event is valid for most elements.
* Bubbles: Yes
* Cancelable: Yes
* Context Info: screenX, screenY, clientX, clientY, altKey, ctrlKey, shiftKey, metaKey, button, detail"
Any suggestion? Thanks.
REF: http://www.w3.org/TR/DOM-Level-2-Events/events.html[^]