A
Alexander Higgins
Hello,
I would like to thank everyone for there help in advance. I have form
which is using an iframe as a Rich Text Editor. Everything works as
expected in IE but I have two issues with Firefox. I am using the
following to make the frame editable:
tmp=document.getElementById("adeditor").contentWindow.document
tmp.designMode="On";
First, Firefox does not seem to accept the unselectable="on" or "off"
attributes in elements in the iframe. Is there any way to prevent
firefox users from editing or change HTML tags in the IFRAME.
Also, I can't seem to add events handlers in firefox. For example, in
the IFrame if I put onmouseover="alert('hello'); the alert fires in IE,
but not Firefox. To sum up what I am trying to accompish, I want to
allow users to edit the Iframe's text contents but there are hyperlinks
in the Iframe that I want to allow users to edit the href attribute,
but not the innertext.
I have input text boxes on the web page, and as user's type the
corresponding elements of each input is updated with the text a user
type's. When a user clicks on a textbox that is set to update a
hyperlink href in the Iframe, I am using javascript to select the
element and fire the execCommand("CreateLink");
In IE, after selecting the range and creating the hyperlink, the
element is no longer selected so if a user goes to update a different
hyperlink, the new link is selected. However, In firefox, after a user
updates the hyperlink, the element is still selected. When a user
tries to update a different link, the old link is still selected, and
the update link tries to update the previously selected link not the
one that is currently selected.
I think the problem is in firefox, when I call the
obj.contentWindow.document.createRange();, i need to have the
createRange() start at the begin of the Iframes contents, and not at
the beginning of the currently selected element.
There is obviously alot of code going on here, but here is the
pertinent snippet.
var obj = document.getElementById("adeditor");
var doc = obj.contentWindow.document;
var
website=document.getElementById("adeditor").contentWindow.document.getElementById(id);
var agt=navigator.userAgent.toLowerCase();
var is_opera=(agt.indexOf("opera")!=-1);
var is_ie=((agt.indexOf("msie")!=-1)&&!is_opera);
if (doc)
{
var sText;
var content;
if (is_ie){
var sText = doc.body.createTextRange();
sText.findText(website.innerText);
sText.select();
}
else
{
sText = obj.contentWindow.document.createRange();
sText.selectNode(website);
content=sText.toString();
obj.contentWindow.find(website.innerHTML);
}
if (sText!="")
{//create link
if (is_ie){
doc.execCommand("CreateLink");
}
else {
linkWin=window.open('/usercontrols/createlink.htm?adeditor','linkw','status=0,channelmode=0,directories=0,location=0,menubar=0,resizable=0,scrollbars=0,toolbar=0,
height=140, width=400
,left='+(screen.width/2-200)+',top='+(screen.height/2-70));
if(linkWin)linkWin.focus();
}
Again any help is appreciated. To see the exact issue, go to the
folliwng web page and click on the full listing radio button. Please
note, I am still working on this so..... It may or may not be
functional when you visit. Thanks again
Here's the page....
http://www.seniorsa2z.com/addesigner.aspx
I would like to thank everyone for there help in advance. I have form
which is using an iframe as a Rich Text Editor. Everything works as
expected in IE but I have two issues with Firefox. I am using the
following to make the frame editable:
tmp=document.getElementById("adeditor").contentWindow.document
tmp.designMode="On";
First, Firefox does not seem to accept the unselectable="on" or "off"
attributes in elements in the iframe. Is there any way to prevent
firefox users from editing or change HTML tags in the IFRAME.
Also, I can't seem to add events handlers in firefox. For example, in
the IFrame if I put onmouseover="alert('hello'); the alert fires in IE,
but not Firefox. To sum up what I am trying to accompish, I want to
allow users to edit the Iframe's text contents but there are hyperlinks
in the Iframe that I want to allow users to edit the href attribute,
but not the innertext.
I have input text boxes on the web page, and as user's type the
corresponding elements of each input is updated with the text a user
type's. When a user clicks on a textbox that is set to update a
hyperlink href in the Iframe, I am using javascript to select the
element and fire the execCommand("CreateLink");
In IE, after selecting the range and creating the hyperlink, the
element is no longer selected so if a user goes to update a different
hyperlink, the new link is selected. However, In firefox, after a user
updates the hyperlink, the element is still selected. When a user
tries to update a different link, the old link is still selected, and
the update link tries to update the previously selected link not the
one that is currently selected.
I think the problem is in firefox, when I call the
obj.contentWindow.document.createRange();, i need to have the
createRange() start at the begin of the Iframes contents, and not at
the beginning of the currently selected element.
There is obviously alot of code going on here, but here is the
pertinent snippet.
var obj = document.getElementById("adeditor");
var doc = obj.contentWindow.document;
var
website=document.getElementById("adeditor").contentWindow.document.getElementById(id);
var agt=navigator.userAgent.toLowerCase();
var is_opera=(agt.indexOf("opera")!=-1);
var is_ie=((agt.indexOf("msie")!=-1)&&!is_opera);
if (doc)
{
var sText;
var content;
if (is_ie){
var sText = doc.body.createTextRange();
sText.findText(website.innerText);
sText.select();
}
else
{
sText = obj.contentWindow.document.createRange();
sText.selectNode(website);
content=sText.toString();
obj.contentWindow.find(website.innerHTML);
}
if (sText!="")
{//create link
if (is_ie){
doc.execCommand("CreateLink");
}
else {
linkWin=window.open('/usercontrols/createlink.htm?adeditor','linkw','status=0,channelmode=0,directories=0,location=0,menubar=0,resizable=0,scrollbars=0,toolbar=0,
height=140, width=400
,left='+(screen.width/2-200)+',top='+(screen.height/2-70));
if(linkWin)linkWin.focus();
}
Again any help is appreciated. To see the exact issue, go to the
folliwng web page and click on the full listing radio button. Please
note, I am still working on this so..... It may or may not be
functional when you visit. Thanks again
Here's the page....
http://www.seniorsa2z.com/addesigner.aspx