Ad

How Do Display Iframe Inside Laravel Blade

- 1 answer

I've been working on a project with pure vanilla html and php and I want to transfer it to laravel. Now I'm stuck when I want to show an iframe (a blade file) inside another page (another blade file). The parent page is displaying but the iframe is bringing 404 (not found) error. Below is my code:

Note that these two files are in the same folder in the "view" directory.

parent.blade.php

<iframe src="child.blade.php">Your browser isn't compatible</iframe>

route

Route::group(['prefix' => 'parent'], function () {
    Route::get('/', '[email protected]');
    Route::get('/child', '[email protected]');
});

controllers

public function index()
{
   return view('folder/index');
}

public function child()
{
   return view('folder/child');
}
Ad

Answer

It should be the URL of the route not the view path:

//parent.blade.php

<iframe src="{{url('parent/child')}}">Your browser isn't compatible</iframe>
Ad
source: stackoverflow.com
Ad