
December 22nd, 2002, 06:39 AM
|
|
Junior Member
|
|
Join Date: Aug 2002
Location: Auckland, New Zealand
Posts: 3
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
[javascript] pasteHTML changing text
Hi All,
I am having trouble using the pasteHTML function in javascript for my online WYSIWYG editor.
Here is the javascript code (loc is the location of the link):
PHP Code:
function sendLink(loc) {
var win1 = "";
if(document.linkForm.window.value == "new") {
win1 = "target=\"_new\"";
//window.alert(win1);
}
var selectedText = window.opener.editFrame.document.selection.createR ange();
var text = selectedText.htmlText;
var link = "<A HREF=\""+loc+"\" "+win1+">"+text+"</A>";
window.alert(link);
selectedText.pasteHTML(link);
window.close();
}
The code is in a popup window and inserts a link in the editFrame of the parent window.
The alert box might say the following:
<A HREF="airport.htm" target="_new">Airport Link</A>
but it inserts the following
<A target=_new HREF="airport.htm">Airport Link</A>
which wont open in a new window.
Unfortunately I dont think I can use execCommand for this.
Thanks in advance for any help and Seasons Greetings to you all
theghostofbob
|