- iPhone topik
- Két nap múlva itt a Xiaomi 17, van egy pár hivatalos fotó is róla
- Realme GT 2 Pro - papírforma
- Redmi Note 10 Pro - majdnem minden stimmel
- Apple iPhone 16 Pro - rutinvizsga
- Motorola Edge 40 - jó bőr
- Merész dizájn és új teleobjektív az iPhone 17 Pro mobilokban
- Hivatalos a OnePlus 13 startdátuma
- Google Pixel 10 Pro XL – tíz kicsi Pixel
- Apple Watch Sport - ez is csak egy okosóra
-
Mobilarena
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
- Milyen monitort vegyek?
- gban: Ingyen kellene, de tegnapra
- Ubiquiti hálózati eszközök
- Milyen egeret válasszak?
- iPhone topik
- AMD K6-III, és minden ami RETRO - Oldschool tuning
- Két nap múlva itt a Xiaomi 17, van egy pár hivatalos fotó is róla
- exHWSW - Értünk mindenhez IS
- Wise (ex-TransferWise)
- Könyvajánló
- További aktív témák...
- Bomba ár! Acer Nitro V - i5-6300HQ I 8GB I 128SSD + 1TB I GTX960 4G I 15,6" FHD I Cam I W10 I Gari!
- Bomba ár! Acer Aspire 7 - i7-7700HQ I 16GB I 256SSD I 15,6" FHD I GTX1050 I Cam I W11 I Gari!
- ASUS ROG Strix G15 gamer laptop, i5-10300H, GTX 1650 Ti, makulátlan állapotban
- Bomba ár! Acer A515-55 - i7-10GEN I 16GB I 256SSD I 15,6" FHD I Intel Iris Plus I Cam I W11 I Gari!
- MSI RTX 5080 16GB GDDR7 SHADOW 3X OC EDITION - Új, 3 év garancia - Eladó!
- Fotó állvány eladó
- Apple iPhone 14 128 GB Fehér 1 év Garancia Beszámítás Házhozszállítás
- ÁRGARANCIA!Épített KomPhone i5 13400F 16/32/64GB RAM RTX 5070 12GB GAMER PC termékbeszámítással
- BESZÁMÍTÁS! ASUS A620M R7 7700X 32GB DDR5 1TB SSD RX 7900 XTX 24GB ZALMAN I3 NEO EVGA 850W
- Bomba ár! Dell Latitude E7270 - i7-6GEN I 8GB I 256GB SSD I 12,5" HD I HDMI I CAM I W10 I Gari!
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest