This only works in IE, not in Firefox etc.

Last post 11-22-2009, 11:08 PM by Kenneth. 3 replies.
Sort Posts: Previous Next
  •  11-21-2009, 7:56 AM 57331

    This only works in IE, not in Firefox etc.

    Hi.
     
    I have put two new buttons in, but when i hit them, nothing happens, only in IE. The buttons do the following:
     
    Opens a new form (called getLink.aspx). On the form user chose a link, and close the form again. Then the link is insert into cuteeditor.
     
    My code look like this:
     

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm19.aspx.vb" Inherits="Aspergerforeningen.WebForm19" %>
    <%
    @ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="ce" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script language="JavaScript" type="text/javascript">
    function ShowMyDialog(button) {
    var editor1 = document.getElementById('<%=Editor1.ClientID%>');
    var editselection = editor1.GetSelection();
    var r = editselection.createRange();

     

    //use CuteEditor_GetEditor(elementinsidetheEditor) to get the cute editor instance
    var editor = CuteEditor_GetEditor(button);
    //show the dialog page , and pass the editor as newwin.dialogArguments
    //(handler,url,args,feature)
    var newwin = editor.ShowDialog(null, "getLink.aspx?link=" + r.htmlText, editor, "dialogWidth:530px;dialogHeight:330px");

    }

    function ShowMyDialog2(button2) {
    var editor1 = document.getElementById('<%=Editor1.ClientID%>');
    var editselection = editor1.GetSelection();
    var r = editselection.createRange();
    //use CuteEditor_GetEditor(elementinsidetheEditor) to get the cute editor instance
    var editor = CuteEditor_GetEditor(button2);
    //show the dialog page , and pass the editor as newwin.dialogArguments
    //(handler,url,args,feature)

    var newwin = editor.ShowDialog(null, "linksideOpret.aspx", editor, "dialogWidth:1000px;dialogHeight:600px");
    }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <
    head runat="server">
    <title></title>
    </
    head>
    <
    body>

    <form id="form1" runat="server">
    <div>
    <ce:Editor ID="Editor1" runat="server" DisableItemList="Save,linktree,codes,images,formatblock"
    Height="750px" ThemeType="Office2007" Width="560px"></ce:Editor>

    </div>
    </form>
    </
    body>
    </
    html>

     
    And the codebehind:
     

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim pos As Integer
    pos = Editor1.ToolControls.IndexOf("InsertLink") + 1
    Dim ctrl As System.Web.UI.WebControls.WebControl
    ctrl = Editor1.CreateCommandButton(
    "MyButton", "list_links.gif", "Indst link til eksisterende side")
    ctrl.Attributes(
    "onclick") = "ShowMyDialog(this)"
    Editor1.InsertToolControl(pos, "MyButton", ctrl)
    pos = Editor1.ToolControls.IndexOf(
    "InsertLink") + 2
    ctrl = Editor1.CreateCommandButton(
    "MyButton2", "linkSideOpret.gif", "Opret linkside")
    ctrl.Attributes(
    "onclick") = "ShowMyDialog2(this)"
    Editor1.InsertToolControl(pos, "MyButton2", ctrl)

    Editor1.EditorBodyStyle = "font-family: Verdana; font-size: 12px;color: #000000;"
    Editor1.SecurityPolicyFile = "Admin.config"
    Editor1.SetSecurityFilesGalleryPath("~/log/")
    Editor1.SetSecurityImageGalleryPath(
    "~/log/")
    Editor1.SetSecurityGalleryPath(
    "~/log/")
    Editor1.SetSecurityFlashGalleryPath(
    "~/log/")
    Editor1.SetSecurityMaxImageSize(
    "1000")
    Editor1.SetSecurityTemplateGalleryPath(
    "~/log/skabeloner")

    End Sub
     
    Kindly PeterDK
  •  11-22-2009, 2:52 AM 57333 in reply to 57331

    Re: This only works in IE, not in Firefox etc.

    Half the problem solved.
     
    If figured out, that this is the problem: (text marked with yellow)
     

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm19.aspx.vb" Inherits="Aspergerforeningen.WebForm19" %>
    <%
    @ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="ce" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script language="JavaScript" type="text/javascript" >
    function ShowMyDialog(button) {
    var editor = CuteEditor_GetEditor(button);
    var newwin = editor.ShowDialog(null, "getLink.aspx?link=" + getTekst()
    , editor,
    "dialogWidth:400px;dialogHeight:240px");

    }

     

    function getTekst() {
    var editor1 = document.getElementById('<%=Editor1.ClientID%>');
    var editselection = editor1.GetSelection();
    var r = editselection.createRange();
    return r.htmlText;
    }
    </script>
     
    A soon as the Java code is using af variable the window dont open. If i just type in something, like this :

    var
    newwin = editor.ShowDialog(null, "getLink.aspx?link=" + "this is a test",
     
    everything works fine. Is it at java problem, or is it the cute soft editor? (Im not the best java programmer, so it's proplaby me :-))
     
    Anybody have a idea?
     
    Kindly PeterDK
  •  11-22-2009, 4:09 AM 57334 in reply to 57331

    Re: This only works in IE, not in Firefox etc.

    I get this error in Safari (no other browser produce any error codes)
     
     
    What the f... is happening.
     
    Anyboddy???
  •  11-22-2009, 11:08 PM 57339 in reply to 57334

    Re: This only works in IE, not in Firefox etc.

    Hi PeterDK,
     
    Try this way
     
    1. function ShowMyDialog(button)   
    2. {   
    3.     var editor1 = document.getElementById('<%=Editor1.ClientID%>');   
    4.     var editwin = editor1.GetWindow();   
    5.     var editdoc = editor1.GetDocument();   
    6.     var editor = CuteEditor_GetEditor(button);   
    7.     var r=null;   
    8.          //for ie   
    9.     if (document.selection && document.selection.createRange)   
    10.         {   
    11.             var editselection = editor1.GetSelection();   
    12.             r = editselection.createRange();   
    13.             var newwin = editor.ShowDialog(null"getLink.aspx?link=" + r.htmlText, editor, "dialogWidth:530px;dialogHeight:330px");   
    14.         }   
    15.         //for firefox safari chrome   
    16.     else if (window.getSelection)   
    17.         {   
    18.              r=editwin.getSelection();   
    19.              if (r.rangeCount > 0 && window.XMLSerializer)   
    20.                 {   
    21.                      r=r.getRangeAt(0);   
    22.                      var newwin = editor.ShowDialog(null"getLink.aspx?link=" + r.htmlText, editor, "dialogWidth:530px;dialogHeight:330px");                          
    23.                  }   
    24.               else  
    25.               {   
    26.               alert("type something in editor and try again")   
    27.               }   
    28.          }   
    29. }  

    Regards,
     
    ken
View as RSS news feed in XML