...

View Full Version : Iframe ExecCommand Hyperlink problem



3lions
06-08-2004, 12:53 PM
I am having a very odd problem with using IFrames as a wysiwyg editor

I am using the editor to enter information into a db and also edit the information in the db.

The inputting works fine and any links i add work correctly. However if i then go to edit the data when i put the info through the editor the second time it breaks the link by adding a bit at the beginning of the HREF (example below)

If the link was href="http://www.bbc.co.uk" when it is edited and saved it becomes
href='http://intranet/test/"http://www.bbc.co.uk"'
(with the beginning bit being the root of the page)

This is really annoying as this happens even when the link is not touched second time around.

Any Ideas??

starrwriter
06-09-2004, 02:24 AM
I am having a very odd problem with using IFrames as a wysiwyg editor

I am using the editor to enter information into a db and also edit the information in the db.

The inputting works fine and any links i add work correctly. However if i then go to edit the data when i put the info through the editor the second time it breaks the link by adding a bit at the beginning of the HREF (example below)

If the link was href="http://www.bbc.co.uk" when it is edited and saved it becomes
href='http://intranet/test/"http://www.bbc.co.uk"'
(with the beginning bit being the root of the page)

This is really annoying as this happens even when the link is not touched second time around.

Any Ideas??

It seems to be default behavior for IE-based editors to convert link paths to absolute on saving the page or toggling between HTML and WYSIWYG mode. In the WYSIWYG editor I developed the only way I could get around this was by adding the copy and paste code to the toggle script. Don't ask me why it works, but it does.

function doToggleView() {
//----- Convert WYSIWYG editor to HTML -----
if(viewMode == 1) {
iHTML = iView.document.body.innerHTML;
iView.document.body.innerText = iHTML;
iView.focus();
viewMode = 2;
//----- Convert HTML editor to WYSIWYG -----
} else{
txtRange = iView.document.body.createTextRange();
txtRange.select();
txtRange.execCommand("Copy");
txtRange.execCommand("Paste");
iText = iView.document.body.innerText;
iView.document.body.innerHTML = iText;
iView.focus();
viewMode = 1;
}
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum