Hi, i have made a plugin that opens up a dialogue where you can select a page from our cms, and then the javascript sets the selected text to a link with the correct url, and it all works perfectly. However, how do i get it to still create the link but put in some default text like "New Link" if there is no text selected in the editor. This is my code at the moment:
function texteditor_browser(sURL)
{
// get the fck editor object
var oEditor = window.parent.InnerDialogLoaded();
var FCK = oEditor.FCK;
// get selected text
var sSelected = (oEditor.FCKBrowserInfo.IsGecko) ? FCK.EditorWindow.getSelection() : FCK.EditorDocument.selection.createRange().text;;
// check that something is selected
if(sSelected)
{
// set selected text to a link
oLink = FCK.CreateLink(sURL);
}
else
{
// alert that nothing is selected
alert('Please select some text in order to create a link');
}
// close dialogue
window.parent.close();
}
Thanks,
Jack
function texteditor_browser(sURL)
{
// get the fck editor object
var oEditor = window.parent.InnerDialogLoaded();
var FCK = oEditor.FCK;
// get selected text
var sSelected = (oEditor.FCKBrowserInfo.IsGecko) ? FCK.EditorWindow.getSelection() : FCK.EditorDocument.selection.createRange().text;;
// check that something is selected
if(sSelected)
{
// set selected text to a link
oLink = FCK.CreateLink(sURL);
}
else
{
// alert that nothing is selected
alert('Please select some text in order to create a link');
}
// close dialogue
window.parent.close();
}
Thanks,
Jack
RE: Create link plugin, help with default tex