Re: CuteEditor In a Child Window

  •  02-23-2004, 6:56 PM

    Re: CuteEditor In a Child Window

    mgjunk,

     

    I just wrote a fix for this. It works. You can test it in our online demo.

     

    Please check it out.

     

    Dad.asp


    <HTML>

    <HEAD>

    <SCRIPT>

    function popupCuteEditor(v_form, v_field)

    {

         var newWin, v_pagestring;

         w = 740;

         h = 300;

         LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;

         TopPosition = (screen.height) ? (screen.height-h)/2 : 0;

         settings = 'height='+h+',width='+w+',top='+TopPosition+',left=';

         v_pagestring = "kid.asp?form=" + v_form + "&field=" + v_field;

         newWin =window.open(v_pagestring,"HTMLEdit",settings + LeftPosition+'resizable=yes')

    }

    </SCRIPT>

    <TITLE>Parent Page</TITLE>

    </HEAD>

    <BODY>

          <FORM name="f1" action="kid.asp" method=POST target='kid' onSubmit="updateitems.asp">

                 <textarea name="t1" cols="42" rows="5">Text Area 1 Text</textarea><br>

                 <input type="button" value="Edit In CuteEditor" name="B1" onclick="popupCuteEditor('f1','t1')">

                 <p></p>

     

                <textarea rows="5" name="t2" cols="42">Text Area 2 Text</textarea><br>

                <input type="button" value="Edit In CuteEditor" name="B2" onclick="popupCuteEditor('f1','t2')">

                <p>

                    <INPUT type="submit" value=Submit>

               </p>

         </FORM>

    </BODY>

    </HTML>

     

    kid.asp


    <!-- #include file = "include_CuteEditor.asp" -->

    <HTML>

    <HEAD>

    <script>

          // querystring

         // Call function by x = querystring("variable") returns variable=x

         function querystring(key)

         {

             var value = null;

             for (var i=0;i<querystring.keys.length;i++)

             {

                 if (querystring.keys[i]==key)

                 {

                      value = querystring.values[i];

                      break;

                 }

             }

            return value;

         }

         querystring.keys = new Array();

         querystring.values = new Array();

         function querystring_parse()

         {

              var query = window.location.search.substring(1);

              var pairs = query.split("&");

              for (var i=0;i<pairs.length;i++)

              {

                  var pos = pairs[i].indexOf('=');

                  if (pos >= 0)

                  {

                      var argname = pairs[i].substring(0,pos);

                      var value = pairs[i].substring(pos+1);

                      querystring.keys[querystring.keys.length] = argname;

                      querystring.values[querystring.values.length] = value;

                  }

              }

         }

         querystring_parse();

        

          // Set the parent windows form and field to a variable

          var v_parentform, v_field, v_form;

          v_field = querystring("field");

          v_form = querystring("form");

          var v_parent = "window.opener.";

          v_parentform = eval(v_parent + v_form);

     

          function tellDad()

          {

               //Editor1 is the ID of the Editor

               var editor = document.getElementById("Editor1_editBox");

               v_parentform.elements[v_field].value=editor.innerHTML;

          }

          

          function Onload()

          {

              getparentdata();

               resizeWindow();

          }

         

          function getparentdata()

          {

              //Editor1 is the ID of the Editor

              var editor = document.getElementById("Editor1_editBox");

              editor.innerHTML = v_parentform.elements[v_field].value;

           }

          

           function resizeWindow() {

                var iWidth = 720 + 18;

                var iHeight = 350 + 44;

                window.resizeTo(iWidth,iHeight)

          }

    </SCRIPT>

    <TITLE>Kid Child Window</TITLE>

    </HEAD>

    <BODY onload="Onload()" bgcolor="#EAF6ED">

    <FORM name="f2" method=POST >

        <%

             dim content

             Dim editor

             Set editor = New CuteEditor

             editor.ID = "Editor1"

             editor.Text = content

             editor.FilesPath = "/ASP/CuteEditor_Files"

             editor.ImageGalleryPath = "/Uploads"

             editor.MaxImageSize = 50

             editor.DisableItemList = "Save"

             'editor.AutoConfigure = "EnableAll"

             'editor.Template= "Bold,Italic,Underline"

             'editor.StyleSheetPath = "/grey2.css"

             'editor.Width = 740

             editor.Height = 240

             editor.Draw()

             ' Request.Form(ID) access from other page

      %>

    <br>

    <INPUT type="button" value='Change Parent value' onClick="tellDad(); window.close();" >

     

    </FORM>

    </BODY>

    </HTML>


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View Complete Thread