- Megjelent a Poco F7, eurós ára is van már
- Mobil flották
- Yettel topik
- One mobilszolgáltatások
- Telekom mobilszolgáltatások
- Apple iPhone 16 Pro - rutinvizsga
- iPhone topik
- Samsung Galaxy S25 Ultra - titán keret, acélos teljesítmény
- Samsung Galaxy S23 Ultra - non plus ultra
- A sógorokhoz érkezik a kompakt Vivo X200 FE
-
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
- OLED TV topic
- Mini-ITX
- Magga: PLEX: multimédia az egész lakásban
- A Bosch szerint Európának nem kellene az AI-t a halálba szabályozni
- Synology NAS
- Fortnite - Battle Royale & Save the World (PC, XO, PS4, Switch, Mobil)
- Renault, Dacia topik
- Mibe tegyem a megtakarításaimat?
- Megjelent a Poco F7, eurós ára is van már
- Milyen billentyűzetet vegyek?
- További aktív témák...
- Újszerű Anker 778 12 in 1 Thunderbolt 4 Docking station dokkoló (Windows, MAC OS)
- Asus TUF Gaming A15 FA506 - 15.6"FHD 144Hz - Ryzen 5 7535HS - 16GB - 512GB SSD - RTX 3050 -3 év gari
- Legion 5 16IRX9 16" QHD+ IPS i5-13450HX RTX 4060 16GB 512GB NVMe magyar vbill gar
- LG UltraGear 27GR95QL-B LoL Edition OLED Monitor! 2560x1440 / 240Hz / 0.03 ms / G-Sync!
- XPS 14 9440 14.5" FHD+ IPS Intel Ultra 7 155H 16GB 512GB NVMe ujjlolv IR kam gar
- VÉGKIÁRUSÍTÁS - REFURBISHED - Lenovo ThinkPad 40AC Thunderbolt 3 docking station
- ÁRGARANCIA! Épített KomPhone Ryzen 5 7600X 32/64GB DDR5 RTX 5060Ti 8GB GAMER PC termékbeszámítással
- Telefon felvásárlás!! iPhone 12 Mini/iPhone 12/iPhone 12 Pro/iPhone 12 Pro Max
- LG 55G4 - 55" OLED evo - 4K 144Hz & 0.1ms - MLA Plus - 3000 Nits - NVIDIA G-Sync - FreeSync Premium
- BESZÁMÍTÁS! ASUS ROG STRIX Z390-E GAMING alaplap garanciával hibátlan működéssel
Állásajánlatok
Cég: CAMERA-PRO Hungary Kft
Város: Budapest
Cég: Promenade Publishing House Kft.
Város: Budapest