document.designMode的功能與使用方法介紹_javascript技巧

來源:互聯網
上載者:User
將文檔設定為設計模式 
      要將整個文檔設定為設計模式,可以對文檔對象本身設定 designMode 屬性。當文檔處於設計模式時,將不運行指令碼。這樣,似乎在文檔內設定一個按鈕來開啟或關閉設計模式是個好注意,但這樣做沒有作用。當使用者開啟它後,它將保持在設計模式狀態。當他們下次單擊此按鈕時,它將被選定而不是被單擊,他們再次單擊它,將能夠編輯它的值。這就是為什麼如果要使用設計模式最好對架構或 IFrame 中的文檔設定 designMode 屬性的原因。下例展示如何為 IFrame 中的文檔開啟設計模式:  
複製代碼 代碼如下:

<script for="btnDesign" event="onclick">  
targetDoc = document.frames(0).document;  
if (targetDoc.designMode == "On")  
          targetDoc.designMode = "Off";  
else  
          targetDoc.designMode = "On";  
</script>  
<button id=btnDesign>DesignMode</button>  
<iframe src="blank.htm" style="border: black thin; width:100%; height:200px"></iframe>  
       designMode 屬性的值始終以首字母大寫格式儲存,即時它最初是以全部小寫設定的。請在測試它的值時一定記住這點。designMode 屬性的預設值是“Inherit”。 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.