W
William Starr Moake
This is for a browser-based WYSIWYG editor to convert image file paths
from absolute to relative when the page under construction is saved.
From inside the save function I get error message: "Cannot assign to
function result." If I place just the HTML.replace part of the
conversion script inside the save function and the rest outside, the
error message is "imgSrcArray undefined." Can anyone figure out what
is wrong with this path conversion script? The save function works by
itself.
function saveFrame() {
imgSrcArray() = new Array
if(imgSrc.indexOf("\\") > -1)
{
slash = imgSrc.lastIndexOf("\\");
imgSrcArray[imgSrcArray.length][0] = imgSrc
imgSrcArray[imgSrcArray.length][1] = imgSrc.substring(slash + 1,
imgSrc.length);
}
if(imgSrc.indexOf("/") > -1)
{
slash = imgSrc.lastIndexOf("/");
imgSrcArray[imgSrcArray.length][0] = imgSrc
imgSrcArray[imgSrcArray.length][1] = imgSrc.substring(slash + 1,
imgSrc.length);
}
for (i=0; i<imgSrcArray.length; i++)
{
HTML = HTML.replace("<img src='"+imgSrcArray[0],"<img
src='"+imgSrcArray[1])
}
var html = iView.document.documentElement.outerHTML;
iView.document.write(HTML);
iView.document.execCommand("SaveAs");
}
from absolute to relative when the page under construction is saved.
From inside the save function I get error message: "Cannot assign to
function result." If I place just the HTML.replace part of the
conversion script inside the save function and the rest outside, the
error message is "imgSrcArray undefined." Can anyone figure out what
is wrong with this path conversion script? The save function works by
itself.
function saveFrame() {
imgSrcArray() = new Array
if(imgSrc.indexOf("\\") > -1)
{
slash = imgSrc.lastIndexOf("\\");
imgSrcArray[imgSrcArray.length][0] = imgSrc
imgSrcArray[imgSrcArray.length][1] = imgSrc.substring(slash + 1,
imgSrc.length);
}
if(imgSrc.indexOf("/") > -1)
{
slash = imgSrc.lastIndexOf("/");
imgSrcArray[imgSrcArray.length][0] = imgSrc
imgSrcArray[imgSrcArray.length][1] = imgSrc.substring(slash + 1,
imgSrc.length);
}
for (i=0; i<imgSrcArray.length; i++)
{
HTML = HTML.replace("<img src='"+imgSrcArray[0],"<img
src='"+imgSrcArray[1])
}
var html = iView.document.documentElement.outerHTML;
iView.document.write(HTML);
iView.document.execCommand("SaveAs");
}