Forums
This topic is locked
last path problem
Posted 25 Apr 2004 23:12:07
1
has voted
25 Apr 2004 23:12:07 William Moake posted:
The last major hurdle in the WYSIWYG editor I'm putting together has me stumped. It involves the type of path used when an image is inserted into the page under construction.This script works to convert the absolute path to relative path if it's in the insert image function:
if(imgSrc.indexOf("\\"
![](/images/forum/smilies/icon_smile_wink.png)
slash = imgSrc.lastIndexOf("\\"
![](/images/forum/smilies/icon_smile_wink.png)
imgSrc = imgSrc.substring(slash + 1, imgSrc.length); }
if(imgSrc.indexOf("/"
![](/images/forum/smilies/icon_smile_wink.png)
slash = imgSrc.lastIndexOf("/"
![](/images/forum/smilies/icon_smile_wink.png)
imgSrc = imgSrc.substring(slash + 1, imgSrc.length); }
But the editor must use the absolute path in the insert image function so the image will be displayed on the page in WYSIWYG mode. With a relative path, only an image placeholder is displayed without the correct image width and height and this causes problems in laying out the page.
I need to place the path conversion script in the following save function so the relative path won't be converted until the page is saved in the same folder/directory as the image:
function saveFrame() {
var html = iView.document.documentElement.outerHTML;
iView.document.write(html_txt);
iView.document.execCommand('SaveAs',null,'index for homepage');
}
The problem is I can't get the path conversion script to work in the saveFrame function. Either I get error message "object expected" or the path is not converted. I even tried using onsave or onsaveFrame = conversion script as separation function relPath() in the image insert function, but this doesn't work either (error message says can't use one function at termination of another function.)
Without this fix, the user will have to manually delete all absolute image paths before he uploads the page to his web host and that is a real hassle for WYSIWYG users.
Can anyone tell me how to write the path conversion script into the save function so that it works? I'm out of ideas.