Hartmut: TextRange

Beitrag lesen

Wer weiß, wie man mit dem textRange-Objekt gezielt Attribute von HTML-Tags ansprechen kann. Geht das überhaupt?

  • Damit habe ich bisher herumprobiert:

<html>
<head>
<title>TEST</title>
<script language="javascript">
function copy1()
{
   textRange1 = document.body.createTextRange();
   textRange1.moveToElementText(listTable);
   textRange1.execCommand("Copy");
}
function copy2()
{
   textRange2 = document.body.createTextRange();
   textRange2.moveToElementText(test);
   textRange2.execCommand("Copy");
}
function copy3()
{
   textRange2 = document.body.createTextRange();
   textRange2.moveToElementText(hallo);
   textRange2.execCommand("Copy");
}

</script>

</head>
<body>

<p>Hallo, dies ist ein Test</p>
<p><a href="javaScript:copy1()">copy1</a></p>
<p><a href="javaScript:copy2()">copy2</a></p>
<p><a href="javaScript:copy3()">copy3</a></p>

<table name="listTable" id="listTable">
  <tr>
    <td>Dies wird durch copy1 in ie Zwischenablage kopiert ...</td>
  </tr>
</table>

<p name="test" id="test">ich heisse hartmut!</p>
<span name="hallo" id="hallo" title="ich bin ein ruediger">test</span>

<form>
<input name="formularfeld" type="text" value="hallo welt!!!!">
</form>

</body>

</html>