SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wysiwyg Editor error - Not An Object

    Hello Folks, been making some changes to the following Javascript that I have. Using Microsofts properiety in IE (ie execCommand.. ) to script an editor I have come across an error.

    The problem is with the part in bold since it appears (to me anyway ) that the rest is okay ?

    PHP Code:
    <script language="javascript1.2" type="text/javascript">
        
        function 
    TestForEditor() {
            
            if(
    document.getElementById('WYSIWYG_DynamicEditor')) {
                
    //
                
    WYSIWYG_DynamicEditor.document.designMode 'on';
                
                
    editorObj                     document.getElementById('WYSIWYG_DynamicEditor').style;
                
    editorObj.width             "95%";
                
    editorObj.height            "192px";
                
    editorObj.font                "12px letter gothic, courier new";
                
    editorObj.color                "rgb(255, 152, 080)";
                
    editorObj.backgroundColor    "rgb(031, 087, 127)";
                
    editorObj.visibility        "visible";
                
    //
                //
                
    configure                    = new Object();
                
    configure.toolbar            = [ ['bold''italic''underline'], ['cut''copy'], ['createlink'], ['htmlmode'] ];
                
    configure.btnList            = {
                
                    
    // buttonName:    commandID,               title,                onclick,                   image,             
                    
    "bold":           ['Bold',                 'Bold',               'editor_action(this.id)',  'bold.gif'],
                    
    "italic":         ['Italic',               'Italic',             'editor_action(this.id)',  'italic.gif'],
                    
    "underline":      ['Underline',            'Underline',          'editor_action(this.id)',  'underline.gif'],
                    
    "cut":            ['Cut',            'Cut',          'editor_action(this.id)',  'cut.gif'],
                    
    "copy":            ['Copy',            'Copy',          'editor_action(this.id)',  'copy.gif'],
                    
    "createlink":     ['CreateLink',           'Insert Web Link',    'editor_action(this.id)',  'link.gif']};
                
                var 
    toolbar "";
                  
    // var btnGroup, btnItem, aboutEditor;
                  
    for(var btnGroup in configure.toolbar) {
                    for(var 
    btnItem in configure.toolbar[btnGroup]) {
                          var 
    btnObj             configure.btnList[btnName];
                        var 
    btnName         configure.toolbar[btnGroup][btnItem].toLowerCase();
                        if(
    btnObj) { 
                            var 
    btnCmdID   btnObj[0];    // command
                            
    var btnTitle   btnObj[1];    // title
                            
    var btnOnClick btnObj[2]; // event handler
                            
    var btnImage   btnObj[3];    // image
                            // begin to build required button
                            //
                            
    toolbar += '<img class="WYSIWYG_DynamicEditor" onClick="' btnOnClick +'" title="' btnTitle '" id="' btnCmdID '" src="images/editor/' btnImage '" />&nbsp;';
                          }
                    }
                } 
                
    document.getElementById('WYSIWYG_DynamicEditor').insertAdjacentHTML('afterEnd'toolbar);
            }
        }
        
        function 
    editor_action(button_id) {
            [
    B]WYSIWYG_DynamicEditor.execCommand(button_idfalsenull);[/B]        
        }
        
        
    </script>
    </head>
    <body marginheight="16" marginwidth="0" topmargin="16" leftmargin="0" onLoad="TestForEditor();"> 
    The first parameter of execCommand() has to be typeof string; which it is. Can anyone help me out here... It's really been a while since I've used Javascript...

    Thanks in advance folks.

  2. #2
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone ? Umm...

  3. #3
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The error I get is this one:

    Code:
    Object doesn't support this property or method.
    WYSIWYG_DynamicEditor is an object though, as defined at the beginning, and a TEXTAREA does have the ID as WYSIWYG_DynamicEditor. Just can't understand it really ?

  4. #4
    SitePoint Wizard silver trophy Crazybanana's Avatar
    Join Date
    Mar 2003
    Location
    In tha fruit cellar
    Posts
    1,379
    Mentioned
    32 Post(s)
    Tagged
    1 Thread(s)
    i got the same error message on line 60 when i tryed it.
    line 60 = onLoad="TestForEditor();"> and a syntax error on line 55 wich is : WYSIWYG_DynamicEditor.execCommand(button_id, false, null);

    tested in (buggy) ie 5.5
    Who's to doom when the judge himself is dragged before the bar


  5. #5
    Non-Member
    Join Date
    Jan 2003
    Posts
    5,748
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yip - That's the blighter... Downloaded IE6 SP1 to see if it was a browser issue and nope, still no luck. The actual script methodology works as I've seen other scripts working with my IE so I'm lost as to why I get this error...

    Going to use the original version for now and comment out the functionality I don't need and attempt a re-write again later.

    Thanks for testing the script and for your help


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •