`
thinkerAndThinker
  • 浏览: 282858 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

document.execCommand()的用法。

 
阅读更多


<input type=button value=剪切 onclick=document.execCommand('Cut')>
<input type=button value=拷贝 onclick=document.execCommand('Copy')>
<input type=button value=粘贴 onclick=document.execCommand('Paste')>
<input type=button value=撤消 onclick=document.execCommand('Undo')>
<input type=button value=重做 onclick=document.execCommand('Redo') id=button2 name=button2>
<input> www.jbxue.com
<input type=button value=删除 onclick=document.execCommand('Delete')>
<input type=button value=黑体 onclick=document.execCommand('Bold')>
<input type=button value=斜体 onclick=document.execCommand('Italic')>
<input type=button value=下划线 onclick=document.execCommand('Underline')>
<input type=button value=停止 onclick=document.execCommand('stop')>
<input type=button value=保存 onclick=document.execCommand('SaveAs')>
<input type=button value=另存为 onclick=document.execCommand('Saveas',false,'c:\\test.htm')>
<input type=button value=字体 onclick=document.execCommand('FontName',false,fn)>
<input type=button value=字体大小 onclick=document.execCommand('FontSize',false,fs)>
<input type=button value=刷新 onclick=document.execCommand('refresh',false,0)>

 

分享到:
评论

相关推荐

    document.execCommand()的用法

    下面的示例展示了如何使用`document.execCommand()`进行简单的文本格式化操作: ```html &lt;textarea id="editor"&gt;&lt;/textarea&gt; &lt;button onclick="document.execCommand('bold', false, null)"&gt;加粗 &lt;button onclick="...

    html中的内容直接下载到excel中,替换 document.execCommand(‘saveAs’)方法

    传统的做法是使用`document.execCommand('saveAs')`方法,但这个方法在某些现代浏览器中已被废弃,因此需要寻找替代方案。本篇文章将详细探讨如何在不依赖`execCommand('saveAs')`的情况下,实现HTML内容直接下载到...

    document.execCommand()解析

    本文将深入探讨`document.execCommand()`的使用方法、适用场景以及相关知识点。 一、基本概念 `document.execCommand()`是浏览器提供的一个全局方法,用于执行一系列富文本编辑命令。这些命令涵盖了从简单的文本...

    javascript document.execCommand() 常用解析

    在HTML5中,这种方式不再推荐使用,但对于旧版本的浏览器仍有必要了解这些命令的使用方法。 `document.execCommand()`命令执行时,通常需要文档处于可编辑状态(`document.designMode = 'on'`),或者文档中某部分...

    IE图片缓存document.execCommand(&quot;BackgroundImageCache&quot;,false,true)

    为了解决这个问题,Erik发现了一个简单的方法,利用`document.execCommand`这个命令,结合特定的参数,可以强制IE6缓存背景图片。具体代码如下: ```javascript document.execCommand("BackgroundImageCache", ...

    document.execCommand()的用法小结

    总的来说,虽然 `document.execCommand()` 在某些情况下仍然有用,但在新的项目中,开发者应该考虑使用更现代和标准化的方法来处理富文本编辑。如果仍然需要使用 `document.execCommand()`,则建议先检查浏览器支持...

    【JavaScript源代码】js实现复制粘贴的两种方法.docx

    这种方法利用了`document.execCommand`API,它允许执行一系列编辑命令(如复制、剪切等)。此API已经被浏览器逐步弃用,但在某些情况下仍可使用。以下是具体实现步骤: 1. **创建一个隐藏的输入框**:用于放置待...

    HTML_Button[1].onclick_事件汇总

    这些操作都是通过调用 document 对象的 execCommand 方法来实现的。 4. 其他类 * window.location="view-source:" + window.location.href:查看源文件 * window.external.ShowBrowserUI('LanguageDialog', null)...

    input按钮onclick事件大全

    这些操作主要适用于IE浏览器,因为`document.all`是IE特有的属性,并且`ExecWB`方法也是IE专有的。 #### 2. 页面刷新 - **`window.location.reload()`**:这行代码用于重新加载当前页面。这对于用户想要更新页面...

    JSP调用ie菜单命令

    IE浏览器(Internet Explorer)提供了一系列的方法来支持这些功能,其中最常用的是`document.execCommand`方法。 #### 二、`document.execCommand`方法详解 `document.execCommand`是HTMLDocument接口的一个方法,...

    cument.execCommand()用法深入理解

    `document.execCommand()`的基本用法是调用该函数并传入一个命令字符串,这个命令字符串代表了你要执行的操作。例如,`document.execCommand('bold', false, null)`会将当前选中的文本设置为粗体。第二个参数通常为`...

    JS粘贴文本到剪贴板

    首先,我们需要了解早期的`document.execCommand()`方法。这是一个在DOM上执行命令的函数,其中包括“copy”和“paste”命令。例如,当用户触发一个复制事件时,可以这样实现: ```javascript function copyText() ...

    javascript-document对象详解(下).zip

    `document`对象还包含事件处理,如`document.addEventListener`用于注册事件监听器,以及`document.execCommand`用于执行某些富文本编辑操作。可能还会涉及`document.readyState`,它表示文档加载状态,以及`...

    js复制文本(文本框、隐藏域、选择文本)

    要复制文本框的内容,可以利用`select()`方法来选取其内容,然后调用`document.execCommand('copy')`来执行复制操作: ```javascript input.select(); document.execCommand('copy'); ``` 对于隐藏域(`...

    html中js点击一键复制功能,兼容各大浏览器

    `document.execCommand()`已经过时,但仍然在一些老版本的浏览器中支持,而`navigator.clipboard.writeText()`是更现代且推荐的方法,它符合W3C的标准。 1. **使用`document.execCommand()`** 这个方法在过去被...

    网页制作必备(最常用javascript onclick语句40条)

    &lt;INPUT onclick="document.execCommand('Underline')" type=button value=»&gt; ``` 对选中文本应用加粗、斜体或下划线格式。 ### 21. 停止加载 ```html &lt;INPUT onclick="document.execCommand('stop')" type=button...

    Javascript代码实现浏览器菜单命令.doc

    使用 document.execCommand("open") 可以实现打开命令,该命令可以打开当前网页。 示例代码:&lt;a href="#" onclick=document.execCommand("open")&gt;打开 2. 使用记事本编辑命令的实现 使用 location.replace("view-...

    excCommand命令

    `execCommand` 是一个在早期浏览器中广泛使用的非标准 JavaScript 方法,主要用于实现富文本编辑器的功能。通过调用 `document.execCommand`,开发者能够轻松地执行一系列与编辑文档相关的操作,如格式化文本、插入...

    vb6_Webbrowser控件使用技巧

    3. **方法3**:使用`execCommand`插入文本框 ```vb Dim o As Object Set o = WebBrowser1.Document.selection.createRange o.execCommand "InsertTextArea", False, "xxx" ``` 以上三种方法都可以实现在...

Global site tag (gtag.js) - Google Analytics