What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » General » Forum & Website » Url link button

Url link button
Author: Message:
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: Url link button
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 :P

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
[Image: dt2.0v2.png]      Happy Birthday, WDZ
11-16-2005 05:08 AM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Url link button - by John Anderton on 11-15-2005 at 10:20 AM
RE: Url link button - by ShawnZ on 11-15-2005 at 01:38 PM
RE: Url link button - by -dt- on 11-15-2005 at 02:07 PM
RE: Url link button - by John Anderton on 11-15-2005 at 05:28 PM
RE: Url link button - by WDZ on 11-15-2005 at 06:28 PM
RE: Url link button - by ShawnZ on 11-15-2005 at 10:29 PM
RE: Url link button - by -dt- on 11-16-2005 at 05:08 AM
RE: Url link button - by John Anderton on 11-16-2005 at 05:45 PM
RE: Url link button - by -dt- on 11-17-2005 at 01:48 AM
RE: Url link button - by John Anderton on 11-17-2005 at 08:45 AM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On