MyBB Community Forums

Full Version: In posting url's - using highlighted text
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there anyway when posting and adding URL's to use the highlighted text as the title of the link?

Kind of how it does for bold, italic.

-Paul
do you mean having titles for links?

like this link? ?

if so then you can use the url tag

[ url=address.com]Text [ /url]
Yes, but I want to use any highlighted text in the post as the url. Highlight some text and hit bold to see what I mean.
I don't understand you... o_O;
If you have highlighted text in your reply and you hit bold, underline, color, font - any of those - it will put the tags AROUND the highlighted text.

I want it to do this:
Highlight a word in a post/reply
Hit the URL button
Prompt comes up for the URL ONLY (or the title is pre-filled in with whatever I highlighted
[ url=http://www.url.com]highlighted text would be here[/url ]

URLs without the [url] tag: ex: http://www.test.com will become hyperlinks on their own, so it's pointless to have a button that will do that.
I think the solution might be in codebuttons.js

function insertHyperlink() {
	var url = prompt("Please enter the URL of the website.", "http://");
	if(url) {


		var urltitle = prompt("If you wish to, you may also insert a title to be shown instead of the URL.", "[color=red]SELECTED TEXT WOULD GO HERE[/color]");


		if(urltitle) {
			doInsert("[url="+url+"]"+urltitle+"[/url]", "", false);

		} else {
			doInsert("[url]"+url+"[/url]", "", false);
		}
	} else {
		alert("Error!\n\nYou did not enter a URL for the website. Please try again.");
	}
}

I just have no idea how to put the selected/highlighted text in a variable to use in that JavaScript.