[JS] Big bug
Utilisateur anonyme
-
Utilisateur anonyme -
Utilisateur anonyme -
Bonjour,
j'ai un code javascript qui devrait au clic sur un lien ajoutter un contenu dans une textarea, mais il ne fonctionne plus ! Le voici :
j'ai un code javascript qui devrait au clic sur un lien ajoutter un contenu dans une textarea, mais il ne fonctionne plus ! Le voici :
<script type="text/javascript">
function insertTag(startTag, endTag, textareaId, tagType) {
var field = document.getElementById(textareaId);
var scroll = field.scrollTop;
field.focus();
if (window.ActiveXObject) { // C'est IE
var textRange = document.selection.createRange();
var currentSelection = textRange.text;
textRange.text = startTag + currentSelection + endTag;
textRange.moveStart("character", -endTag.length - currentSelection.length);
textRange.moveEnd("character", -endTag.length);
textRange.select();
} else { // Ce n'est pas IE
var startSelection = field.value.substring(0, field.selectionStart);
var currentSelection = field.value.substring(field.selectionStart, field.selectionEnd);
var endSelection = field.value.substring(field.selectionEnd);
field.value = startSelection + startTag + currentSelection + endTag + endSelection;
field.focus();
field.setSelectionRange(startSelection.length + startTag.length, startSelection.length + startTag.length + currentSelection.length);
}
field.scrollTop = scroll; // et on redéfinit le scroll.
}
function actions(text) {
text = ' ' + text + '';
if (document.post.comment_final.createTextRange && document.post.message.caretPos) {
var caretPos = document.post.comment_final.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + '' : text;
document.post.comment_final.focus();
} else {
document.post.comment_final.value += text;
document.post.comment_final.focus();
}
}
</script>
A voir également:
- [JS] Big bug
- Macos big sur - Guide
- Hiberfil.sys too big - Guide
- Bug chromecast - Guide
- Round js ✓ - Forum Javascript
- Bug localisation snap ✓ - Forum Snapchat