- Luck Dragon: Asszociációs játék. :)
- Oldman2: A KOReader ebook olvasó program
- Mr Dini: Mindent a StreamSharkról!
- MasterDeeJay: Egy nem átlagos Asus videókártya (GTX950M 2GB GDDR3)
- sziku69: Szólánc.
- sziku69: Fűzzük össze a szavakat :)
- Luck Dragon: MárkaLánc
- GoodSpeed: Samsung DV90DG52A0ABLE hőszivattyús szárítógép
- Gurulunk, WAZE?!
- D1Rect: Nagy "hülyétkapokazapróktól" topik
-
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
- XFX Radeon RX 580 GTS XXX Edition 8GB GDDR5 256bit
- Samsung 28" T28E310EW LED Televízió-monitor eladó
- HP All In One Pc HP 23.8"FHD/Ultra 5 125U /16GB/512GB SSD/HP GARANCIA
- Thrustmaster TS-PC Racer Ferrari 488 Challenge - Új, 2 év gyártói garanciával
- Lenovo Yoga 7 2in1 OLED FHD+ Ultra 5 125H 16 GB DDR5 7467 MHz Magyar helyszíni garancia 2028.06.
- Apple iPhone 17 256GB Bontatlan Független Összes Szín / 27% áfás ár INGYENES SZÁLLÍTÁS
- ASUS TUF A15 - 15.6"FHD 144Hz - Ryzen 7 7445HS - 16GB - 512GB - Win11 - RTX 3050 - Garancia
- AKCIÓ! Lenovo Legion Pro 5 WQXGA GAMER notebook - i9 14900HX 32GB DDR5 1TB SSD RTX 5070 8GB
- Motorola Edge 50 Neo 256GB,Újszerű,Dobozaval,12 hónap garanciával
- Új és régi konzolok Okosítása és Szoftveres szintű javítása - PS4 "okosító" lemez kapható!
Állásajánlatok
Cég: Laptopműhely Bt.
Város: Budapest
