Javascript URL/Hyperlink inserter?
Started by Chris., May 13 2007 06:16 PM
2 replies to this topic
#1
Posted 13 May 2007 - 06:16 PM
I was wondering how to make the thing that uses javascript to insert a url with BBCode. Like the thing on IPB when you make a post, and click the insert hyperlink button, it pops up that textarea thing, then you type in the url, and then you click okay, then you type in what you want the link to look like. If you click the insert hyperlink button (
) while making a post, you will notice what I mean.
#2
Posted 13 May 2007 - 09:36 PM
If you have a normal BBCode JavaScript snippet for inserting the code into the textfield that is already set up, then its simple.
Quick Example:
function bbcodelink(txtarea){
var my_link = prompt('Enter URL:', 'http://');
if(my_link == null) return false;
if(my_link.length < 6){
alert('This URL is not valid!');
return false;
}
return bbcode(txtarea, '[url='+my_link+']', '[/url]');
}
Quick Example:
<textarea id="comment" name="comment"></textarea><br /><a href="java script:void(0);" onclick="bbcodelink('comment');" title="Add Link"><img src="/images/link.png" alt="" /></a>
#3
Posted 13 May 2007 - 10:05 PM
Thanks for that.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
