- Milyen belső merevlemezt vegyek?
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- RAM topik
- Milyen videókártyát?
- Azonnali alaplapos kérdések órája
- SSD kibeszélő
- Házi barkács, gányolás, tákolás, megdöbbentő gépek!
- LG LCD és LED TV-k
- HDD probléma (nem adatmentés)
- AMD K6-III, és minden ami RETRO - Oldschool tuning
-
PROHARDVER!
JavaScript != Java (A JavaScript nem összekeverendő a Javával, két különböző programozási nyelvről van szó!)
Új hozzászólás Aktív témák
-
btz
addikt
Ezt próbálgattam már. Nálam nem működik (szokás szerint)
Először így próbáltam:
<script type="text/javascript" >
// Create a fake textarea
const textAreaEle = document.createElement('textarea');
// Reset styles
textAreaEle.style.border = '0';
textAreaEle.style.padding = '0';
textAreaEle.style.margin = '0';
// Set the absolute position
// User won't see the element
textAreaEle.style.position = 'absolute';
textAreaEle.style.left = '-9999px';
textAreaEle.style.top = `0px`;
// Set the value
textAreaEle.value = text;
// Append the textarea to body
document.body.appendChild(textAreaEle);
// Focus and select the text
textAreaEle.focus();
textAreaEle.select();
// Execute the "copy" command
try {
document.execCommand('copy');
} catch (err) {
// Unable to copy
} finally {
// Remove the textarea
document.body.removeChild(textAreaEle);
}
</script>Ekkor a textAreaEle.value = text; érték nem volt definiálva így készítettem neki egy változót. var text = "tesztszöveg";
<script type="text/javascript" >
// Create a fake textarea
const textAreaEle = document.createElement('textarea');
// Reset styles
textAreaEle.style.border = '0';
textAreaEle.style.padding = '0';
textAreaEle.style.margin = '0';
// Set the absolute position
// User won't see the element
textAreaEle.style.position = 'absolute';
textAreaEle.style.left = '-9999px';
textAreaEle.style.top = `0px`;
var text = "tesztszöveg";
// Set the value
textAreaEle.value = text;
// Append the textarea to body
document.body.appendChild(textAreaEle);
// Focus and select the text
textAreaEle.focus();
textAreaEle.select();
// Execute the "copy" command
try {
document.execCommand('copy');
} catch (err) {
// Unable to copy
} finally {
// Remove the textarea
document.body.removeChild(textAreaEle);
}
</script>Hiba: Uncaught TypeError: Cannot read property 'appendChild' of null.
Beraktam bodyba a scriptet, utána semmit nem csinált, viszont a hiba megszűnt.
Aztán a document.body részt cseréltem document.getElementById("mainContent").appendChild(textAreaEle);-re. Így már megjelenik a textarea, benne a tesztszöveg felirattal. (A kódból kitöröltem azt a részt ami elrejti a textarea-t).<html>
<body>
<div id="mainContent">
MAIN CONTENT<br />
</div>
<script type="text/javascript" >
// Create a fake textarea
const textAreaEle = document.createElement('textarea');
var text = "tesztszöveg";
// Set the value
textAreaEle.value = text;
// Append the textarea to body
document.getElementById("mainContent").appendChild(textAreaEle);
// Focus and select the text
textAreaEle.focus();
textAreaEle.select();
// Execute the "copy" command
try {
document.execCommand('copy');
} catch (err) {
// Unable to copy
} finally {
// Remove the textarea
//document.body.removeChild(textAreaEle);
}
</script>
</body>
<html>Viszont nem másol semmit a vágólapra.
Új hozzászólás Aktív témák
- Autós topik
- Eredeti játékok OFF topik
- Milyen belső merevlemezt vegyek?
- One otthoni szolgáltatások (TV, internet, telefon)
- Milyen okostelefont vegyek?
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- RAM topik
- Luck Dragon: Asszociációs játék. :)
- Apple iPhone 16 Pro - rutinvizsga
- Milyen videókártyát?
- További aktív témák...
- Samsung Galaxy A23 5G 128GB, Kártyafüggetlen, 1 Év Garanciával
- Xiaomi Redmi Note 14 5G 256GB, Kártyafüggetlen, 1 Év Garanciával
- Eladó Logitech Z5500 7.1 aktív sub 2db hangszóróval
- Újszerű Asus ROG Strix G16 G614 -16" WUXGA 165Hz - i5-13450HX - 16GB - 512GB - RTX 4050 -1,5 év gari
- Asztali PC , R5 4500 , 1080 8GB , 16GB RAM , 256GB m.2 , 750GB HDD
- Bomba ár! HP ProBook 440 G7 - i5-10GEN I 8GB I 256SSD I HDMI I 14" FHD I Cam I W11 I Gar
- Apple iPhone 13 Pro Max / 128GB / Kártyafüggetlen
- BESZÁMÍTÁS! Gigabyte AORUS B550M R7 5700X 32GB DDR4 1TB SSD RX 6800 16GB Zalman i3 NEO Gigabyte 850W
- ÁRGARANCIA!Épített KomPhone i7 14700KF 32/64GB RAM RX 9070 XT 16GB GAMER PC termékbeszámítással
- HPE Aruba PoE+ L3 switch raktárról azonnal elérhető!
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest