在 laravel 刀片视图中使用 iframe
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41355348/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
using iframe in laravel blade view
提问by Kash
I have a web site with a page having web form to enter data into mysql database. Now requirement has changed and I need to convert the whole web site to laravel.
我有一个网站,页面上有一个网页表单,可以将数据输入到 mysql 数据库中。现在需求发生了变化,我需要将整个网站转换为 Laravel。
In current web page there is index.php which has a menu strip and a iframe. on clicking a menu item the linked page is opened in the Iframe. Now How to achieve the same flexiblity using Laravel.
在当前的网页中有 index.php,它有一个菜单条和一个 iframe。单击菜单项时,链接页面将在 Iframe 中打开。现在如何使用 Laravel 实现相同的灵活性。
How to redirect/route the web form in the iframe.
如何在 iframe 中重定向/路由 Web 表单。
Below is the index.php
下面是 index.php
<html>
<head>
<script type="text/javascript" src="JS/header.js"></script>
<link href="css/stylesheets.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="menustrip">
<ul>
<li><a href="index.php" onclick="OpenForm('register.php');">Register</a></li>
<li><a href="index.php" onclick="OpenForm('search.php');">Search</a></li>
</ul>
</div>
<div class="iframe" style="position:fixed;top:62px; left:0; width:100%; height:100%;" >
<iframe name="main" id="main" src="" frameborder="0" width="99%" height="95%" align="left"><FONT FACE=ARIAL SIZE=3 COLOR="RED">Your Browser doesn't Support Required Component.</FONT></iframe>
</div>
</body>
</html>
回答by smartworld-dm
You can use iframe in Laravel blade like this.
您可以像这样在 Laravel Blade 中使用 iframe。
This is for local .html file(file in public dir)
这是用于本地 .html 文件(公共目录中的文件)
<iframe src="{{URL::to('/')}}/your file path here" width="100%" height="600"></iframe>
This is for the online url
这是在线网址
<iframe src="http://www.onlineicttutor.com/wp-content/uploads/2016/04/pdf-at-iframe.pdf" width="100%" height="300"></iframe>
回答by Zenel Rrushi
I think that the OpenForm()
functions just sets the src of the iframe to the register.php in first case and to search.php so instead of going to register.php
or search.php
you define these at the route file.
in Route.php define the register
Ex:
我认为这些OpenForm()
函数只是在第一种情况下将 iframe 的 src 设置为 register.php 和 search.php 所以而不是去register.php
或者search.php
你在路由文件中定义这些。在 Route.php 中定义register
Ex:
Route::get('register', function () {
//code to go here or use controllers
return view('register');
});
Then just set the src of the iframe to register and you will have the same approach as your site in core PHP.
然后只需将 iframe 的 src 设置为注册,您将拥有与核心 PHP 中的站点相同的方法。