N
Next Generation Technologies Inc.
Now what I have is a function that only works in WinIE4+ because it's
uses Microsoft proprietary properties and methods:
This function HTML tags around selected text in a textarea for a CMS.
It does this in response to keyboard events thus making a simplistic,
through-the-web markup editor for textareas. For example, you select
some text in the textarea, hit a key combo and bang, your select text
is bounded by <strong> tags. Occasionally it may hit the user with a
prompt to fill in a value for the tag attribute.
Kinda quick and nifty huh?
The problem is it only works in Internet Explorer. What I'd like is
some suggestions on how to change this script so that it works in
Mozilla1, Firefox and heck maybe even Opera 7.5 or Safari. I am
completely willing to sacrifice backward compatibility with anything
less than IE6.
I'd like suggestions that bring this function into close compliance
with the W3C's DOM/ECMA rec but if I must use a little proprietary
stuff for it work in the above browsers, I'm okay with that.
Any suggestions?
uses Microsoft proprietary properties and methods:
Code:
function gmshortcutkeys() {
if ((parseInt(navigator.appVersion) >= 4) && (navigator.appName ==
"Microsoft Internet Explorer")) {
if (event.ctrlKey != true) return;
gmselection = document.selection.createRange().text;
if (window.event.keyCode == 1) {
gminsertlink = prompt("What do you want to link to?",
"http://")
if (gminsertlink == null) return;
document.selection.createRange().text = '<a href="' +
gminsertlink + '">' + gmselection + '</a>';
return;
}
if (window.event.keyCode == 2) {
document.selection.createRange().text = '<strong>' +
gmselection + '</strong>';
return;
}
if (window.event.keyCode == 3) {
gminsertacrotitle = prompt("How is this acronym spelled out?",
"Start here")
if (gminsertacrotitle == null) return;
document.selection.createRange().text = '<acronym title="' +
gminsertacrotitle + '">' + gmselection + '</acronym>';
return;
}
if (window.event.keyCode == 4) {
gminsertdfntitle = prompt("How is this jargon or technical
term defined?", "Start here")
if (gminsertdfntitle == null) return;
document.selection.createRange().text = '<dfn title="' +
gminsertdfntitle + '">' + gmselection + '</dfn>';
return;
}
if (window.event.keyCode == 5) {
gminsertdelcite = prompt("Point to the page responsible for
this deletion.", "http://")
if (gminsertdelcite == null) return;
document.selection.createRange().text = '<del datetime="' +
document.lastModified + '" cite="' + gminsertdelcite + '">' +
gmselection + '</del>';
return;
}
}
}
This function HTML tags around selected text in a textarea for a CMS.
It does this in response to keyboard events thus making a simplistic,
through-the-web markup editor for textareas. For example, you select
some text in the textarea, hit a key combo and bang, your select text
is bounded by <strong> tags. Occasionally it may hit the user with a
prompt to fill in a value for the tag attribute.
Kinda quick and nifty huh?
The problem is it only works in Internet Explorer. What I'd like is
some suggestions on how to change this script so that it works in
Mozilla1, Firefox and heck maybe even Opera 7.5 or Safari. I am
completely willing to sacrifice backward compatibility with anything
less than IE6.
I'd like suggestions that bring this function into close compliance
with the W3C's DOM/ECMA rec but if I must use a little proprietary
stuff for it work in the above browsers, I'm okay with that.
Any suggestions?