Hirdetés
- One mobilszolgáltatások
- Poco F8 Ultra – forrónaci
- Google Pixel topik
- Samsung Galaxy A56 - megbízható középszerűség
- Apple Watch Sport - ez is csak egy okosóra
- Xiaomi 15 - kicsi telefon nagy energiával
- Nem engedi el a 128 GB-ot a Google
- Apple iPhone 13 mini - miért nem veszik elegen?
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- EarFun Air Pro 4+ – érdemi plusz
-
Mobilarena
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
- Mini-ITX
- Most tényleg 8 GB VRAM-mal szúrja ki szemünk az NVIDIA??
- PlayStation 5
- Milyen TV-t vegyek?
- Luck Dragon: Asszociációs játék. :)
- DUNE médialejátszók topicja
- AMD Navi Radeon™ RX 9xxx sorozat
- Fujifilm X
- Lenovo Legion Go: a legsokoldalúbb kézikonzol
- One mobilszolgáltatások
- További aktív témák...
- Eladó Konfig I5 7400 16GB DDR4 240GB SSD 512GB HDD GTX1660TI 6GB!
- ÚJ Glorious PC Gaming Race Model WIred O illetve I Bolti ár:14k INGYEN FOXPOST
- ÚJ Glorious PC Gaming Race Model I 2 Wireless Bolti ár:40k INGYEN FOXPOST
- ÚJ Glorious PC Gaming Race Model D/D- USB Bolti ár:10k INGYEN FOXPOST
- ÚJ Glorious Model O 2 Wireless Bolti ár:40k INGYEN FOXPOST
- SteelSeries Apex Gaming billentyűzet, német, RGB
- Beszámítás! LG 32GQ850-B 32 240Hz IPS QHD 1ms monitor garanciával hibátlan működéssel
- ÁRGARANCIA!Épített KomPhone Ryzen 9 5900X 16/32/64GB RAM RTX 5070 12GB GAMER PC termékbeszámítással
- Dell Latitude 7390 13,3" FHD IPS, i5-i7, 8-16GB RAM, SSD, jó akku, számla, 6 hó gar
- Bomba ár! Dynabook Portege X40-K - i5-1240P I 16GB I 256SSD I 14" FHD I Cam I W11 I Garancia!
Állásajánlatok
Cég: Laptopszaki Kft.
Város: Budapest
Cég: Laptopműhely Bt.
Város: Budapest


