- Meggyi001: Anya, tudsz segíteni a matekban?....Nem érek rá kisfiam, majd segít a ChatGPT...
- D1Rect: Nagy "hülyétkapokazapróktól" topik
- sziku69: Fűzzük össze a szavakat :)
- sziku69: Szólánc.
- Luck Dragon: Asszociációs játék. :)
- bambano: Bambanő háza tája
- V.Milán: 04.15. Ki mit csinál ma?
- Brogyi: CTEK akkumulátor töltő és másolatai
- Magga: PLEX: multimédia az egész lakásban
- hcl: Xiaomi pumpa pumpálás
-
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
Hirdetés
- Audi, Cupra, Seat, Skoda, Volkswagen topik
- Motorola Edge 60 Fusion - nem csak a forma időtálló
- NVIDIA GeForce RTX 5080 / 5090 (GB203 / 202)
- Autós topik
- Assassin’s Creed Shadows teszt
- Meggyi001: Anya, tudsz segíteni a matekban?....Nem érek rá kisfiam, majd segít a ChatGPT...
- Ingatlanos topic!
- Milyen autót vegyek?
- TCL LCD és LED TV-k
- Óra topik
- További aktív témák...
- Eladó Wraith Prism AM4 RGB hűtő ÚJ!
- ASUS Maximus IV GENE-Z/GEN3 - Republic of Gamers - Alaplap - Számla + Gari: 12 hó / BeszámítOK!
- MSI B250M MORTAR ARCTIC Fehér Alaplap - Számla + Gari: 12 hó / BeszámítOK!
- MSI Z270 GAMING PRO CARBON Alaplap - Számla + Garancia 12 hó! / BeszámítOK
- Intel Core i5-14400F 10-Core 2.5GHz LGA1700 Box (BX8071514400F) Processzor - Gari: 3év
- BESZÁMÍTÁS! ASROCK H310CM i5 9600K 32GB DDR4 240GB SSD 1TB HDD RX 5700 8GB Rampage SHIVA FSP 600W
- Samsung S23 Ultra 256/8GB Fehér / Új állapotban / Áfás számlávál / 12 hónap jótállás
- Telefon felvásárlás!! iPhone 14/iPhone 14 Plus/iPhone 14 Pro/iPhone 14 Pro Max
- Telefon felváráslás!! Xiaomi 13T, Xiaomi 13T Pro, Xiaomi 14T, Xiaomi 14T Pro
- REFURBISHED és ÚJ - 40AS Lenovo ThinkPad USB-C dokkoló (akár 3x4K felbontás)
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: Laptopszaki Kft.
Város: Budapest