我想在div中显示iframe。我想在iframe中显示数据。所以我试过这样:
NAV-bar.php:
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" title="Report">Report<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
<a href="content.php?report=list" target="iframe_report">Dashboard</a>
</li>
</ul>
</li>
report.php:
<!DOCTYPE html>
<html lang="en">
<head>
<?php include("heading.php"); ?>
</head>
<body role="document">
<?php include("includes/inc-header.php"); ?>
<div class="panel-body">
<div class="col-sm-12">
<iframe id="iframe_report" name="iframe_report" style="border:dotted; width:100%; height:450px;"></iframe>
</div>
</div>
</body>
</html>
content.php:
<?php
include("configuration.php");
$report = $_GET["report"];
$title = $_GET["title"];
$pagetitle = $title;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include("heading.php"); ?>
</head>
<body role="document">
<?php include("nav-bar.php"); ?>
<div class="panel panel-default">
<div class="panel-heading">
<?php echo $title; ?>
<input type="hidden" id="input" name="input" value="<?php echo $report; ?>">
</div>
<div class="panel-body">
<table border="0" cellpadding="0" cellspacing="0" width="100%" id="table_list" class="table table-striped table-bordered hide">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>List</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<script type="text/javascript" language="javascript">
jQuery(document).ready(function() {
jQuery.ajaxSetup({ cache: false });
var input_report = jQuery("#input").val();
var table_id = "#table_report_" + input;
jQuery(table_id).removeClass("hide").addClass("show");
jQuery(table_id).DataTable({
paging: false,
select: true,
ajax: "reports-db.php?report=" + input_report,
});
});
</script>
这就是我的尝试方式。当我单击导航栏中的选项时,应该获取数据并显示在同一页面中。但是,当我点击该选项时,它会在新页面中打开。但是,我想在同一页面中显示它,并且还应显示所有导航栏选项。我想要它的方式是,导航条应该显示在下面,有一个div,在其中应该显示iframe。但是,不知道是什么将它重定向到新窗口。有人可以指导我吗?