D
D
Demon2015-10-15 10:09:13
JavaScript
Demon, 2015-10-15 10:09:13

How to make iframe load and display?

Help me understand and fix the code, it works in both versions ([video] [videos]) when the page is loaded. But if you change the Content Code on click, then the [videos] option from the frame URL does not work and does not display it.
Although under the same conditions, by clicking [video], the full frame works fine.
Example:
There is a BB code in a DIV:

<div class="uc-message">
[videos]https://youtu.be/tKqfeYcvpzk[/videos]
<br>
[video]<iframe src="//vk.com/video_ext.php?oid=-58774696&id=171227922&hash=fea9df74d79b4a0c&hd=2" width="250" height="100"  frameborder="0"></iframe>[/video]    
</div>

There is also js that converts:
$('.uc-message').each(function(){
$(this).html($(this).html().split('[video]').join('').split('[/video]').join(''));  
$(this).html($(this).html().split('[videos]').join('<iframe src="').split('[/videos]').join('" width="250" height="100" frameborder="0"></iframe>'));
});

Demo on jsfiddle

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question