T U T O R I A L S E R I E S
A target="_blank" Quicktag
Create a Quicktag for links you want to open in a new window
This assumes that you are working on an unaltered quicktags.js
In version 2.0 this is in /wp-includes/js
In version 1.5.2 it is in the 'wp-admin' directory.
It is located in the 'wp-admin' directory. Download this using ftp to work on.
Do not just click on it to edit !
Being able to see line numbers will help you.
If you want to add some css to make this appear differently to a normal link, I would think that replacing this line:
edButtons[i].tagStart = '<a href="' + URL + '" target="_blank">';
with this:
edButtons[i].tagStart = '<span class="newwin"><a href="' + URL + '" target="_blank"></span>';
should work but I have not tested it.
Add these lines so they become 60-66
edButtons[edButtons.length] =
new edButton('ed_link2'
,'newlink'
,''
,'</a>'
,'a'
); // special case
Add these so they become 227-229
else if (button.id == 'ed_link2') {
document.write('<input type="button" id="' + button.id + '" accesskey="' + button.access + '" class="ed_button" onclick="edInsertLink2(edCanvas, ' + i + ');" value="' + button.display + '" />');
}
And at the very bottom of the file, put these lines
function edInsertLink2(myField, i, defaultValue) {
if (!defaultValue) {
defaultValue = 'http://';
}
if (!edCheckOpenTags(i)) {
var URL = prompt('Enter the URL' ,defaultValue);
if (URL) {
edButtons[i].tagStart = '<a href="' + URL + '" target="_blank">';
edInsertTag(myField, i);
}
}
else {
edInsertTag(myField, i);
}
}
Now save and upload.
Press CTRL and F5 together (Windows) to hard refresh the quicktags when on the Write screen.
These pages are independent of http://wordpress.org
All design, content & images © Mark 2004-2008. All rights reserved.