mám potíž s kopírováním html pomocí javascriptu.
- Kód: Vybrat vše
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Select text v javascriptu</title>
</head>
<body>
<script language=javascript>
function getSelText()
{
var txt = '';
if (window.getSelection)
{
txt = window.getSelection();
}
else if (document.getSelection)
{
txt = document.getSelection();
}
else if (document.selection)
{
txt = document.selection.createRange().htmlText;
}
else return;
document.aform.selectedtext.value = txt;
findById('trg').innerHTML += txt;
}
document.onkeydown=function(e){
if(e.which == 13) {
findById('trg').innerHTML += "<strong>oki<\/strong>";
}
}
function findById(nazev){
return document.getElementById(nazev);
}
</script>
<p>Lorem Ipsum is simply <strong>dummy</strong> text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<input type="button" value="Get selection" onmousedown="getSelText()">
<form name=aform >
<textarea name="selectedtext" rows="5" cols="20"></textarea>
</form>
<div id="trg"></div>
</body>
</html>
do toho divu (id trg) by se pak mělo vložit ono html ale kopíruje to ten text. Vygooglil jsem nějaká řešení s getrange ale ty nefungují nebo je neumím použít.
Esli jste to někdo řešil pak prosím o radu
