Geat
11-14-2003, 03:21 AM
I'm making a content editor, and one of the features is create hyperlink.
If the user has selected an object (text or an image), they can click the link button and a javascript window allows them to enter the URL etc.
Creating a link from the text works fine, but if the user has selected an image, I get an "Invalid argument" javascript error.
The relevant code is:
lnk = document.createElement("A");
top.opener.prevRange(0).applyElement(lnk);
Where prevRange is a textrange created in the opening window's content.
Incidentally, some people may recognise that this code is from the EWE open source WYSIWG editor.
If the user has selected an object (text or an image), they can click the link button and a javascript window allows them to enter the URL etc.
Creating a link from the text works fine, but if the user has selected an image, I get an "Invalid argument" javascript error.
The relevant code is:
lnk = document.createElement("A");
top.opener.prevRange(0).applyElement(lnk);
Where prevRange is a textrange created in the opening window's content.
Incidentally, some people may recognise that this code is from the EWE open source WYSIWG editor.