Hey,
I need to be able to return true or false in a function to determine if the users cursor is inside a custom tag field.
eg: the HTML code would be
<matt>Cutsom Tag</matt>
and I am trying to use the following code which is called on a keypress....
so basically in the iView (iFrame) when the key is pressed it calls this function... it works perfectly with proper elements, such as <form> or <P> but not with a custom html field.
Is this the correct way to do it? or is there another way??
thanks for any help.
I need to be able to return true or false in a function to determine if the users cursor is inside a custom tag field.
eg: the HTML code would be
<matt>Cutsom Tag</matt>
and I am trying to use the following code which is called on a keypress....
Code:
function isMatt() { iView.focus(); var cursor = iView.document.selection.createRange(); var element = cursor.parentElement(); if (element.nodeName.toLowerCase() == "matt") { //a form has been found return true; } else { while (element.nodeName.toLowerCase() != "matt") { // if there's a parentNode available, work upon that if (element.parentNode) { element = element.parentNode; } if (element.nodeName.toLowerCase() == "matt") { //a form has been found return true; break; } if (element.nodeName.toLowerCase() == "html") { break; } } } }
Is this the correct way to do it? or is there another way??
thanks for any help.
Comment