Habibur Rahman
Habibur Rahman

Reputation: 73

How to embed HTML code in the laravel blade template?

I am trying to built a embed HTML system in where anyone can copy and paste code snippet in his website to display that.For this I have written requied code in the jquery section . I want to pass that code to a specific div so that that code is run as source code.

jquery part :

 $(document).on("click", "#embedLink", function () {
    var textArea=$("#textArea");
    var url = $('#headerInput').val();
    $("#framInput").val(url);
    var iframe =document.getElementById('ifrm');
    var html= '<iframe id="ifrm" src="'+url+'"width="100%" height="600"    frameborder="0"disable></iframe>';
    textArea.append(html);
    
});

blade template:

<div name="" id="textArea">
               
         </div> 

I want to pass the html value in the div(id="textArea") element.And then I want to show like that....

<iframe id="ifrm" src="'+url+'"width="100%" height="600"    frameborder="0"disable></iframe>

How can do that?

Upvotes: 0

Views: 1237

Answers (2)

Habibur Rahman
Habibur Rahman

Reputation: 73

This question is mine.At last I found the answer. I have solved that passing the code as text.

I have solved the problem replacing it..

textArea.append(html);

by the following

textArea.text(html);        

Upvotes: 1

A.A Noman
A.A Noman

Reputation: 5270

You may try this way

textArea.append("<iframe id=\"ifrm\" src="+url+" style=\"width: 100%; height: 600;\" frameborder=\"0\" disable></iframe>");

Upvotes: 1

Related Questions