我想在MVC视图中设置iframe的src属性。我尝试过以下代码,但没有将src属性添加到iframe。
@section Style{
} @*end @section Style*@
@{
Html.RenderAction("HeaderPartial", "Home", new { area = "Common" });
}
<iframe id="iframeProjectView" height="820" width="1665" scrolling="no" style="display: block"></iframe>
@section Script{
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.10.2.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/MicrosoftAjax.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/MicrosoftMvcAjax.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/MicrosoftMvcValidation.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/EventsAssets.js")"></script>
<script type="text/javascript">
var url = "@ViewData["url"]";
var iframe = $("#iframeProjectView");
iframe.attr('src', url);
</script>
@Html.DevExpress().GetScripts(
new Script { ExtensionSuite = ExtensionSuite.NavigationAndLayout },
new Script { ExtensionSuite = ExtensionSuite.GridView },
new Script { ExtensionSuite = ExtensionSuite.Editors }
)
}
&#13;
当我重定向到此视图时,页面不会显示iframe。我还检查了查看源,但它没有将src属性添加到iframe。
有什么想法吗?
谢谢,