SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: wysiwyg problem

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    wysiwyg problem

    hello this code can work :

    Code:
    <html> 
    <head> 
    <title> Using execCommand to bold text </title> 
    <script language="JavaScript"> 
    
    function Init() 
    { 
    iView.document.designMode = 'On'; 
    } 
    
    function boldIt() 
    { 
    iView.document.execCommand('bold', false, null); 
    } 
    
    </script> 
    
    <body > 
    <iframe id="iView" style="width: 200px; height:70px"></iframe> 
    <br><br> 
    <input type="button" onClick="boldIt()" value="Toggle Bold">
    <input type="submit" onclick="Init()">
     
    </body> 
    </html>
    I change it like this :

    Code:
    <html> 
    <head> 
    <title> Using execCommand to bold text </title> 
    <script language="JavaScript"> 
    
    function Init(objec) 
    { 
    objec.document.designMode = 'On'; 
    } 
    
    function boldIt() 
    { 
    iView.document.execCommand('bold', false, null); 
    } 
    
    </script> 
    
    <body > 
    <iframe id="iView" style="width: 200px; height:70px"></iframe> 
    <br><br> 
    <input type="button" onClick="boldIt()" value="Toggle Bold">
    <input type="submit" onclick="Init('iView')">
     
    </body> 
    </html>

    The buttom code can not work in IE 6 SP2

    What should I do ?

  2. #2
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code JavaScript:
    function Init(objec)
    { 
        document.getElementById(objec).document.designMode = 'On'; 
    }
    FOR SALE: 1 set of morals, never used, will sell cheap

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i test it but can not work :


    Code:
    document.getElementById('text1').document.designMode = 'On';
    document.getElementById(objec).document.designMode = 'On';
    only this code work

    Code:
    text1.document.designMode = 'On';

  4. #4
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And using window.frames[0]?
    FOR SALE: 1 set of morals, never used, will sell cheap

  5. #5
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you mean ?
    Code:
    window.frames[0].getElementById(objec).document.designMode = 'On' ?
    I did not use frame in my page

  6. #6
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if this would work, I'm just thinking along.
    But how about something like this?

    Code JavaScript:
     function Init(id) {
        var obj = document.getElementById(id);
        if(obj.document && obj.document.designMode) { 
            obj.document.designMode = "On"; 
        } 
        else if(frames && frames.obj && frames.obj.document.designMode) { 
            frames.obj.document.designMode = "on"; 
        } 
        else if (obj.contentDocument) { 
            obj.contentDocument.designMode = "on"; 
        }
        else {
            alert('Not supported');
        }
    }
    FOR SALE: 1 set of morals, never used, will sell cheap

  7. #7
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No it can not awnser yet

    Is my code complete?

    Code:
    <textarea id="text1"></textarea>
    <script language="javascript">
    function Init(id) {    var obj = document.getElementById(id);    if(obj.document && obj.document.designMode) {         obj.document.designMode = "On";     }     else if(frames && frames.obj && frames.obj.document.designMode) {         frames.obj.document.designMode = "on";     }     else if (obj.contentDocument) {         obj.contentDocument.designMode = "on";     }    else {        alert('Not supported');    }}
    Init('text1');
    </script>

  8. #8
    SitePoint Evangelist hexburner's Avatar
    Join Date
    Jan 2007
    Location
    Belgium
    Posts
    591
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't seem to get this right, apparantly.
    Have you read the docs?

    Internet Explorer - designMode Property (document)
    Mozilla Firefox - Midas Specification
    FOR SALE: 1 set of morals, never used, will sell cheap


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
  •