JavaScript Reference/Javascript Methods/insertAdjacentText — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
 
м (1 версия)
 
(нет различий)

Текущая версия на 08:22, 26 мая 2010

"insertAdjacentText()" Example

    
<html>
<body>
<script language="JavaScript">
function function1() {
   var myText = "Some Sample Text";
   document.all.myDiv.insertAdjacentText("afterBegin", myText); 
} 
</script>
<button onclick="function1();">Insert element</button>
<div id="myDiv" style="width:300; height:200;"></div>
</body>
</html>



"insertAdjacentText()" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<a>                             <address>                     |
|                |<area>                          <b>                           |
|                |<basefont>                      <big>                         |
|                |<blockquote>                    <body>                        |
|                |<button>                        <caption>                     |
|                |<center>                        <cite>                        |
|                |<code>                          <comment>                     |
|                |<custom>                        <dd>                          |
|                |<dfn>                           <dir>                         |
|                |<div>                           <dl>                          |
|                |<dt>                            <em>                          |
|                |<fieldset>                      <font>                        |
|                |<form>                          <frameset>                    |
|                |<hn>                            <hr>                          |
|                |<i>                             <iframe>                      |
|                |<img>                           <input type="button">         |
|                |<input type="checkbox">         <input type="file">           |
|                |<input type="hidden">           <input type="image">          |
|                |<input type="password">         <input type="radio">          |
|                |<input type="reset">            <input type="submit">         |
|                |<input type="text">             <kbd>                         |
|                |<label>                         <legend>                      |
|                |<li>                            <listing>                     |
|                |<map>                           <marquee>                     |
|                |<menu>                          <nobr>                        |
|                |<ol>                            <option>                      |
|                |<p>                             <pre>                         |
|                |<s>                             <samp>                        |
|                |<select>                        <small>                       |
|                |<span>                          <strike>                      |
|                |<strong>                        <sub>                         |
|                |<sup>                           <td>                          |
|                |<textarea>                      <th>                          |
|                |<tt>                            <u>                           |
|                |<ul>                            <var>                         |
+----------------+--------------------------------------------------------------+



"insertAdjacentText()" Syntax, Parameters and Note

Note:
Inserts text into the specified position.
    
Syntax:
    
document.all.elementID.insertAdjacentText(param1, param2)
Parameters:
    param1   Required; 
             beforeBegin          just before the beginning of the element
             afterBegin           just after the beginning of the element
             beforeEnd            just before the end of the element
             afterEnd             just after the end of the element
    param2   Required; the text to be inserted.