- Út Korea turistaparadicsomába, amiről talán még sosem hallottál: Csedzsu-sziget
- Perplexity Pro AI képszerkesztési limit -egy képgenerátor függő tapasztalatai
- Adattár lemez előkészítése Windows telepítéshez
- Jelszóvédett IBM Thinkpad R50e működőképessé tétele.
- ATK Blazing Sky X1 Ultimate Metallic Red gamer egér
- gban: Ingyen kellene, de tegnapra
- D1Rect: Nagy "hülyétkapokazapróktól" topik
- sellerbuyer: Milyen mobiltelefont vegyek 2025 ben?
- Luck Dragon: Asszociációs játék. :)
- sziku69: Fűzzük össze a szavakat :)
- eBay-es kütyük kis pénzért
- Kempingezés és sátrazás
- SzDavid99: Út Korea turistaparadicsomába, amiről talán még sosem hallottál: Csedzsu-sziget
- Elektromos rásegítésű kerékpárok
- sziku69: Szólánc.
-
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
- Ritkaság eladó!!! i5-5675c Iris pro grafikus maggal.
- Szép! Lenovo Thinkpad T14 G3 "Golyóálló" Üzleti Laptop 14" -50% i5-1250P 12Mag 16GB/512GB FHD+ IPS
- Lenovo ThinkPad T14 Gen 1 - Ryzen 5 Pro 4650U, 16GB RAM, 512GB NVMe SSD - Szépséghibával, áron alul!
- Eladó Lg Ultragear Oled 27GR95QE-B, garis 27.02ig
- be quiet! Pure Rock 2 Black 150W TDP Foxpost az árban
- Samsung Galaxy S23+ 512GB, Kártyafüggetlen, 1 Év Garanciával
- HIBÁTLAN iPhone 15 Pro 256GB Blue Titanium -1 ÉV GARANCIA - Kártyafüggetlen, MS3506, 92% Akkumulátor
- Prémium! Gamer PC-Számítógép! Csere-Beszámítás! R 9 9950X / RX 9070XT 16GB / 64GB DDR5 / 1TB 990Pro
- Xiaomi Redmi Note 12 Pro 5G 128GB Kártyafüggetlen 1Év Garanciával
- ÁRGARANCIA!Épített KomPhone i7 14700KF 32/64GB RAM RTX 5090 32GB GAMER PC termékbeszámítással
Állásajánlatok
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest
Cég: CAMERA-PRO Hungary Kft.
Város: Budapest