![]() |
![]() ![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 141 Pomógł: 0 Dołączył: 9.10.2015 Ostrzeżenie: (0%) ![]() ![]() |
Witajcie, jak zrobić, że gdy wkleję w input link do filmiku youtube to nad tym inputem pojawi się iframe z filmikiem.
Przykład iframe . Podacie przykład jak to zrobić? |
|
|
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 6 806 Pomógł: 1828 Dołączył: 11.03.2014 Ostrzeżenie: (0%) ![]() ![]() |
1. Pobrać wartość z tego inputa.
2. Przefiltrować pod kątem poprawność (czy to link do YT). 3a. Jeśli ramki nie ma na stronie, to dodać ją wraz z poprawnym atrybutem src, ustawiony na wartość z punktu 2. 3b. Jeśli ramka jest na stronie, to (zmienić jej wyświetlanie z none na block i) ustawić jej atrybut src. https://developer.mozilla.org/pl/docs/Web/A...nt/setAttribute |
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 141 Pomógł: 0 Dołączył: 9.10.2015 Ostrzeżenie: (0%) ![]() ![]() |
A zrobisz mi przykład?
|
|
|
![]()
Post
#4
|
|
Grupa: Zarejestrowani Postów: 286 Pomógł: 46 Dołączył: 10.01.2016 Ostrzeżenie: (0%) ![]() ![]() |
Kod function addElement () { // create a new div element // and give it some content var newDiv = document.createElement("iframe"); newDiv.setAttribute('width',560); newDiv.setAttribute('height',315); newDiv.setAttribute('src',document.getElementById('text').value); newDiv.setAttribute('frameborder',0); newDiv.setAttribute('allowfullscreen','allowfullscreen'); newDiv.setAttribute('id','divek'); var newContent = document.createTextNode("Hi there and greetings!"); newDiv.appendChild(newContent); //add the text node to the newly created div. // add the newly created element and its content into the DOM var currentDiv = document.getElementById("div1"); document.body.insertBefore(newDiv, currentDiv); } function removeElement(){ document.getElementById('divek').remove(); } document.getElementById('btn').addEventListener('click',addElement,false); document.getElementById('btn2').addEventListener('click',removeElement,false); Template: https://developer.mozilla.org/en-US/docs/We...t/createElement |
|
|
![]() ![]() |
![]() |
Aktualny czas: 24.08.2025 - 20:03 |