- Három játékprofillal készült az új Arc meghajtó
- Befutottak a beágyazott rendszerekbe szánt, tempós Ryzenek
- Mi történik a szemeddel, ha napi 8 órát monitort nézel? | Orvos válaszol
- A Synology visszatáncolt a saját márkás HDD-k megkövetelésének kapcsán
- 350 Hz-es IPS kijelzővel gyarapodott a Samsung portfóliója
-
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
- Külső 3,5'' mobil rack-ek topikja
- Mobilhasználat külföldön
- Épített vízhűtés (nem kompakt) topic
- Könyvajánló
- exHWSW - Értünk mindenhez IS
- Sub-ZeRo: Euro Truck Simulator 2 & American Truck Simulator 1 (esetleg 2 majd, ha lesz) :)
- BestBuy topik
- Arc Raiders
- Kormányok / autós szimulátorok topikja
- Samsung LCD és LED TV-k
- További aktív témák...
- BESZÁMÍTÁS! ASUS B760M i7 13700K 32GB DDR4 512GB SSD RX 6800XT 16GB Phanteks Eclipse P400 Glacier
- GYÖNYÖRŰ iPhone 11 64GB Red -1 ÉV GARANCIA - Kártyafüggetlen, MS3121, 100% Akkumulátor
- BESZÁMÍTÁS! Gigabyte H610M i5 12400F 32GB DDR4 512GB SSD RTX 3060 12GB ZALMAN M4 FSP 700W
- Dell Precision 5820 XL PC - Xeon W-2123 112GB RAM 512GB SSD 1TB HDD RX 580 GTS 8GB Win 11
- Lenovo ThinkPad T14 Gen1 Intel I7 10610U Akció! 11.10.2025-ig kedvezménes, 130.000ft-os áron!
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Laptopműhely Bt.
Város: Budapest