By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

javascript should support in mozilla

P: 12
i have javascript functions in my requirement but htat is working in IE but it is not working in mozilla
Jun 26 '07 #1
Share this Question
Share on Google+
3 Replies


gits
Expert Mod 5K+
P: 5,390
hi ...

please be more specific ... what code is not working ... please post it or post an similar example ... so that we are able to help you ...

kind regards ...
Jun 26 '07 #2

P: 12
thanks i have function like fixing the cursor postion in textarea..like in my text area
i keep my cursor position i should take the value from list initially one by one it will add in the last position as defult but in mozilla its adding only in the first but in Ie it works properly..


function setCursorPos() {
globalCursorPos = getCursorPos(FileColumnData.messageText);


}


function getCursorPos(textElement) {

var sOldText = textElement.value;

var objRange = document.selection.createRange();
var sOldRange = objRange.text;

var sWeirdString = '#%~';

objRange.text = sOldRange + sWeirdString; objRange.moveStart('character', (0 - sOldRange.length - sWeirdString.length));

var sNewText = textElement.value;

objRange.text = sOldRange;

for (i=1; i <= sNewText.length; i++)
{
var sTemp = sNewText.substring(i, i + sWeirdString.length);
if (sTemp == sWeirdString) {
var cursorPos = (i - sOldRange.length);
return cursorPos;
}
}
if(sOldText != "") {
return sOldText.length;
}

return 0;
}

function insertdata()
{
var msg = document.FileColumnData.columnData.value;
var firstPart = FileColumnData.messageText.value.substring(0,globa lCursorPos);
var secondPart = FileColumnData.messageText.value.substring(globalC ursorPos,FileColumnData.messageText.value.length);
document.FileColumnData.messageText.value = firstPart + msg + secondPart ;
document.FileColumnData.messageText.focus();

}
<script>
var globalCursorPos = FileColumnData.messageText.value.length;
</script>

function insertString(stringToInsert) {
var firstPart = FileColumnData.messageText.value.substring(0, globalCursorPos);
var secondPart = FileColumnData.messageText.value.substring(globalC ursorPos,FileColumnData.messageText.value.length);
document.FileColumnData.messageText.value = firstPart + stringToInsert + secondPart;
document.FileColumnData.messageText.focus();
}



this is the code iam using in my jsp
Jun 26 '07 #3

gits
Expert Mod 5K+
P: 5,390
hi ...

how do you refer to the textelement ... the typical way that works in all browsers would be:

Expand|Select|Wrap|Line Numbers
  1. var element_ref = document.getElementById('element_id');
  2. var element_value = element_ref.value;
try to refer that way.

kind regards ...
Jun 26 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.