Javascript Not Working in Firefox

  •  10-31-2009, 5:38 PM

    Javascript Not Working in Firefox

    I built my own CuteEditor hyperlink insertion feature (for various reasons).  Here is what happens...
     
    1.  You click on an ASP/VB.Net ImageButton that opens an AJAX modal popup.
    2.  You input the hyperlink's display text and URL into the modal popup then click an ASP/VB.Net button.
    3.  A Javascript is invoked that formats markup for a hyperlink and inserts it into the CuteEditor window.
     
    This all works perfectly fine in IE.  In Firefox however, you go through all these steps...but no hyperlink appears.  The editor window seems to flash like it does in IE when the hyperlink actually appears...but no hyperlink appears in Firefox.  In Safari (on a Mac)...it's worse...not only does the hyperlink fail to appear...but any text that was already in the editor window disappears.  I will show the code that I use to do all this in hope that perhaps somebody knows what is happening differently between the way IE handles the Javascript and the way Firefox and (especially) Safari handles the Javascript...
     
    First, here is an ASP/VB.Net button that I use to open a modal popup that gets the display text and URL for the hyperlink:

    <
    asp:ImageButton ID="imb_InsertHyperlink" Visible="true" ImageUrl="~/CuteSoft_Client/CuteEditor/Images/link.gif" runat="server" />
     
    This is the button in the modal popup that I use to call the Javascript:

    <
    asp:Button ID="btnInsertHyperlink" Text="Insert" style="width: 115px; " runat="server" OnclientClick="InsertHyperlink(this)" />
     
    Finally, here is the Javascript that I use to insert the hyperlink into the text editor portion of CuteEditor:

    function InsertHyperlink()

    {

    var editor1 = document.getElementById('<% = Editor1.ClientID%>');

     

    var DisplayText = document.getElementById('ctl00$ContentPlaceHolder_Outer$txtInsertHyperlinkDisplayText').value;

    var DisplayURL = document.getElementById('ctl00$ContentPlaceHolder_Outer$txtInsertHyperlinkURL').value;

    var HyperLinkMarkUp = '<a href=\"' + DisplayURL + '\" target="_blank">' + DisplayText + '</a>';

    editor1.ExecCommand('PasteHTML',false,HyperLinkMarkUp);

     

    }

     
View Complete Thread