quote:
Originally posted by ShawnZ
getElementbyName('message').value
=/ theres no command named that.... *goes to the post reply page and tries that
ReferenceError on line 1: getElementbyName is not defined
yea yea just as i thought
anyway to get the current selected text i would use..
code:
if(document.getSelection){
text = window.getSelection().toString();
}
else if(document.selection){
text = document.selection.createRange().text;
}
so something like....
code:
function insertHyperlink() {
if(document.getSelection){
text = window.getSelection().toString();
}
else if(document.selection){
text = document.selection.createRange().text;
}
var url = text;
if(!url) var url = prompt("Please enter the URL of the website.", "http://");
if(url) {
if((typeof(text)!='string')||(!text.match(/http:\/\//))){
var urltitle = prompt("If you wish to, you may also insert a title to be shown instead of the URL.", "");
}else{
var urltitle = false;
}
if(urltitle) {
doInsert("[url="+url+"]"+urltitle+"[/url]");
} else {
doInsert("[url]"+url+"[/url]");
}
} else {
alert("Error!\n\nYou did not enter a URL for the website. Please try again.");
}
}
should work