祝大家十一快乐!!进者有分,顺便提个问题,在js中document.execCommand(“”,“”,“”)中为什么只有IE6.0支持,在IE6.0下要实现相应的函数,如何实现?谢谢!

解决方案 »

  1.   

    IEWebBrowser这个组件的execWB方法。
    1. <object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object> 
    2. 调用方法。 
    WebBrowser.ExecWB nCmdID, nCmdExecOpt, [pvaIn], [pvaOut] 
    3. 参数说明。 
    (a).nCmdID 
    OLECMDID_OPEN = 1, 
    OLECMDID_NEW = 2, 
    OLECMDID_SAVE = 3, 
    OLECMDID_SAVEAS = 4, 
    OLECMDID_SAVECOPYAS = 5, 
    OLECMDID_PRINT = 6, 
    OLECMDID_PRINTPREVIEW = 7, 
    OLECMDID_PAGESETUP = 8, 
    OLECMDID_SPELL = 9, 
    OLECMDID_PROPERTIES = 10, 
    OLECMDID_CUT = 11, 
    OLECMDID_COPY = 12, 
    OLECMDID_PASTE = 13, 
    OLECMDID_PASTESPECIAL = 14, 
    OLECMDID_UNDO = 15, 
    OLECMDID_REDO = 16, 
    OLECMDID_SELECTALL = 17, 
    OLECMDID_CLEARSELECTION = 18, 
    OLECMDID_ZOOM = 19, 
    OLECMDID_GETZOOMRANGE = 20 
    OLECMDID_UPDATECOMMANDS = 21 
    OLECMDID_REFRESH = 22 
    OLECMDID_STOP = 23 
    OLECMDID_HIDETOOLBARS = 24 
    OLECMDID_SETPROGRESSMAX = 25 
    OLECMDID_SETPROGRESSPOS = 26 
    OLECMDID_SETPROGRESSTEXT = 27 
    OLECMDID_SETTITLE = 28 
    OLECMDID_SETDOWNLOADSTATE = 29 
    OLECMDID_STOPDOWNLOAD = 30 
    上面的关键词都可以在浏览器的菜单里面找到对应的选项﹐大家一看就明白的﹗ 
    (b).nCmdExecOpt 
    OLECMDEXECOPT_DODEFAULT = 0, 
    OLECMDEXECOPT_PROMPTUSER = 1, 
    LECMDEXECOPT_DONTPROMPTUSER = 2, 
    OLECMDEXECOPT_SHOWHELP = 3 
    对于这个参数﹐一般来说﹐选1就可以了。 这是调用IE的”另存为”功能的示例﹕ <object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object> 
    <A href="javascript:WebBrowser.ExecWB(4,1);">Save-存储 
      

  2.   

    object.execCommand(sCommand [, bUserInterface] [, vValue]);
    其中sCommand :Required. String that specifies the command to execute. This command can be any of the command identifiers that can be executed in script. 
    bUserInterface: Optional. Boolean that specifies one of the following values. false Default. Does not display a user interface. 
    true Displays a user interface, if the command supports one. 
     vValue :Optional. Variant that specifies the string, number, or other value to assign. Possible values depend on sCommand .ResDo not invoke the execCommand method until after the page loads.The bUserInterface and vValue parameters might be required depending on the command being executed.
    ExampleThe following example shows how to use the CreateLink constant as the sCommand of the execCommand method to allow the user to create a hyperlink from selected text. The scriptMicrosoft&reg; JScript&reg; then retrieves the specified URL and uses it to replace the selected text.HideExample<HTML>
    <BODY>
    <H1 unselectable="on">Creating a Link and Retrieving the URL</H1>
    <script>
    function AddLink()
    {//Identify selected text
    var sText = document.selection.createRange();
    if (!sText==""){
    //Create link
    document.execCommand("CreateLink");
    //Replace text with URL
    if (sText.parentElement().tagName == "A"){
    sText.parentElement().innerText=sText.parentElement().href;
    document.execCommand("ForeColor","false","#FF0033");
    }
    }
    else{
    alert("Please select some blue text!");
    }
    }
    </script>
    <P unselectable="on">Select any portion of the following blue text, such as "My favorite Web site". Click the button to turn the selected text into a link. The text will be changed to the URL that you specify.</P>
    <P style="color=#3366CC">My favorite Web site is worth clicking on. Don't forget to check out my favorite music group!</P>
    <BUTTON onclick="AddLink()" unselectable="on">Click to add link</BUTTON>
    </BODY>
    </HTML>