- Luck Dragon: Asszociációs játék. :)
- Drivv: Prehistorik 2 - Retró Játékpercek! 1. rész
- sziku69: Fűzzük össze a szavakat :)
- D1Rect: Nagy "hülyétkapokazapróktól" topik
- sziku69: Szólánc.
- Elektromos rásegítésű kerékpárok
- Magga: PLEX: multimédia az egész lakásban
- Fogkefe: elektromos vagy manuális?
- user2: Kia Ceed Gold 160 1.5 T-GDI MY2024
- f(x)=exp(x): A laposföld elmebaj: Vissza a jövőbe!
-
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
- Óra topik
- Kerékpársportok
- Hivatalos a OnePlus 13 startdátuma
- Egy szenzor, két zoomkamera: újraírta a Huawei a mobilfotózás történetét
- NVIDIA GeForce RTX 5070 / 5070 Ti (GB205 / 203)
- Milyen belső merevlemezt vegyek?
- Autós topik
- Álláskeresés, interjú, önéletrajz
- Építő/felújító topik
- AMD Catalyst™ driverek topikja
- További aktív témák...
- Lenovo 14,1"Áthajtható Érintős FullHd,Ryzen 3,VEGA VGA,,8-16GB RAM,256-512SSD,Szép állapot
- Fujitsu Celsius H770 Workstation laptop (15,6FHD/Xeon/32GB/512SSD/Nvidia4GB)
- QNAP QSW-1105-5T 5 portos 2.5GbE switch - 1 év garancia
- tp-link BE3600 / Archer BE230 / Dual-Band Wifi 7 Router - 2 èv garancia
- MacBook Air M1 13" 2020 8/256gb Silver
- ÚJ- Lenovo ThinkVision T24i-10 - 24" monitor - Számla, garancia
- LG 65C4 - 65" OLED evo - 4K 144Hz - 0.1ms - NVIDIA G-Sync - FreeSync - HDMI 2.1 - 1000 Nits
- BenQ PD-2700-U Monitor - Designer 4K 27"
- ÚJ Lenovo Yoga Slim 7 - 14.5" 3K OLED Érintő 90Hz - Snapdragon X Elite - 32GB - 1TB - 2,5+év gari
- Intel Core 2 Quad Q9550 2.83GHz LGA775 Processzor
Állásajánlatok
Cég: PC Trade Systems Kft.
Város: Szeged
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest