Hirdetés
- Sub-ZeRo: Euro Truck Simulator 2 & American Truck Simulator 1 (esetleg 2 majd, ha lesz) :)
- sh4d0w: Kalózkodás. Kalózkodás?
- Luck Dragon: Asszociációs játék. :)
- sziku69: Fűzzük össze a szavakat :)
- gban: Ingyen kellene, de tegnapra
- sziku69: Szólánc.
- btz: Internet fejlesztés országosan!
- Pajac: száz pí
- GoodSpeed: Ágymatrac keresési kálvária
- Real Racing 3 - Freemium csoda
-
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
- AMD Ryzen 9 / 7 / 5 9***(X) "Zen 5" (AM5)
- Sweet.tv - internetes TV
- Óvodások homokozója
- Fotók, videók mobillal
- Xiaomi 15T Pro - a téma nincs lezárva
- Intel Core i7-5xxx "Haswell-E/EP" és i7-6xxx "Broadwell-E/EP" (LGA2011-v3)
- Gaming notebook topik
- TCL LCD és LED TV-k
- Sub-ZeRo: Euro Truck Simulator 2 & American Truck Simulator 1 (esetleg 2 majd, ha lesz) :)
- iPhone topik
- További aktív témák...
- MacBook Pro 14 (2021) M1 Pro / 16 GB RAM / 512 GB SSD Új topcase, 100% akku
- Yamaha R-N402D sztereó erősítő
- HP ProBook 450 G7, 15,6" FHD IPS, I5-10210U, 8GB DDR4, 256GB SSD, W11, Számla, 1 év garancia ( olvas
- Apple MacBook Pro M2 12 C 16 GB/ 1 TB HUN 2023
- HP ProBook 440 G7, 14" FHD IPS, I5-10210U, 8GB DDR4, 256GB SSD, W11, Számla, 1 év garancia ( olvasd
- ÚJ Lenovo ThinkPad X13 Gen 5 - 13.3" WUXGA IPS - Ultra 5 135U - 16GB - 512GB - Win11 - 2,5 év gari
- LG 35WN75C-B - 35" Ívelt VA - 3440x1440 - 100Hz 5ms - USB Type-C 60W - AMD FreeSync - HDR 10
- HIBÁTLAN iPhone 14 256GB Starlight -1 ÉV GARANCIA - Kártyafüggetlen, MS3799, 100% Akksi
- BESZÁMÍTÁS! LG UltraGear 32GR93U-B 32 144Hz IPS UHD 1ms monitor garanciával hibátlan működéssel
- HIBÁTLAN iPhone 13 128GB Starlight -1 ÉV GARANCIA - Kártyafüggetlen, MS3432
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
Cég: NetGo.hu Kft.
Város: Gödöllő

