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
35 / Male / Flag
Joined: Mar 2004
RE: Url link button
Blah i just tested it (i didnt test i before :-/ ) and document.getSelection() dosnt work quite right with textarea's (seems when the textarea looses focus it "hides" its selected text untill it refocus's)
so here the code that defintly works (i tested it :P)  , i also changed it a bit because doInsert seems to mess up sometimes (shows undefined :-/)

code:

function insertHyperlink() {

var urltitle = false;
var text;
var start = document.input.message.selectionStart;
var end = document.input.message.selectionEnd;

if(start!=end){
var string = document.input.message.value;
var startString = string.substr(0,start);
var endString = string.substr(end,string.length);
text = string.substr(start,end -start)
}


var url = text;

if(!url){
var url = prompt("Please enter the URL of the website.", "http://");
urltitle = prompt("If you wish to, you may also insert a title to be shown instead of the URL.", "");
if(urltitle){
doInsert("[url="+url+"]"+urltitle+"[/url]");
}else{
doInsert("[url]"+url+"[/url]");
}
return;
}else if(!url.match(/http:\/\//)){
var url = prompt("Please enter the URL of the website.", "http://");
urltitle = text;
}else{
url = text;
}

if(url) {
if(urltitle) {
document.input.message.value = startString + "[url="+url+"]"+urltitle+"[/url]" + endString
} else {
document.input.message.value = startString + "[url]"+url+"[/url]" + endString
}
} else {
alert("Error!\n\nYou did not enter a URL for the website. Please try again.");
}
}

and ja if you want to test install..
http://darktempler.be/gscript/msgplusforumurldifferent.user.js

This post was edited on 11-17-2005 at 02:03 AM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
11-17-2005 01:48 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