- sziku69: Fűzzük össze a szavakat :)
- sziku69: Szólánc.
- eBay-es kütyük kis pénzért
- Luck Dragon: Asszociációs játék. :)
- D@reeo: Pi-hole és a Telekom Sagemcom F@st 5670 DNS beállítása
- Luck Dragon: Alza kuponok – aktuális kedvezmények, tippek és tapasztalatok (külön igényre)
- Lalikiraly: Commodore The C64, Ultimate
- Pajac: Nincs rá kapacitásom
- Brogyi: CTEK akkumulátor töltő és másolatai
- tordaitibi: Moltbook- az AI közösségi platformja
-
LOGOUT
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
- BESZÁMÍTÁS! Gigabyte B450M R5 2600X 16GB DDR4 512GB SSD GTX 1650 4GB ZALMAN T3 Plus Deepcool 400W
- BESZÁMÍTÁS! ASRock A520M R5 3600 16GB DDR4 512GB SSD GTX 1060 6GB ZALMAN T3 Plus Deepcool 400W
- BESZÁMÍTÁS! Gigabyte X570 R7 5700X 32GB DDR4 512GB SSD RX 6750 XT 12GB LIAN LI LANCOOL 216RX 750W
- BESZÁMÍTÁS! Gigabyte Z390 i7 9700K 16GB DDR4 512GB SSD RX 6600 8GB Rampage SHIVA FSP 550W
- BESZÁMÍTÁS! ASRock A520M R5 3600 16GB DDR4 512GB SSD RX 6600 8GB Rampage SHIVA Cooler Master 600W
- Apple iPhone 13 Pro Max Graphite ProMotion 120 Hz, Pro kamerák 128 GB-100%-3hó gari!
- BESZÁMÍTÁS! MSI B760M i5 14400 16GB DDR5 512GB SSD RX 6700 XT 12GB Lian LI LANCOOL 207 GIGABYTE 750W
- Dell Latitude 5410 - 14", i7-10610U, 8-16GB RAM, SSD, jó akku, számla, garancia
- szinteÚJ Dell Pro 14 Ultra 7 255U 16GB DDR5 1TB AI PC FHD+ 1 év garancia
- HIBÁTLAN iPhone 15 Plus 256GB-1 ÉV GARANCIA - Kártyafüggetlen, MS4529
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
