我的asp网页上有一个iframe,我正在从代码后面动态加载一个url。 但是在我在iframe中加载我的网址时,它并没有在Chrome和Safari中打开。 它在IE和FF中完美运行。
任何人都可以帮我解决这个问题。示例代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="a.aspx.cs" Inherits="Admin_Title_a" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<iframe id="ifrm" src="http://www.sample.com/" runat="server"></iframe>
</div>
</form>
</body>
</html>
代码背后:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Admin_Title_a : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
答案 0 :(得分:0)
绝对不需要将runat="server"
用作iframe
标记属性。同时尝试将一些宽度和高度设置为iframe
。试试这个
<iframe id="ifrm" src="http://www.sample.com/" height="300px" width="600px">
<p>Your browser does not support iframe tag.</p>
</iframe>
答案 1 :(得分:0)
尝试将此添加到Page_Load事件
受保护的void Page_Load(object sender,EventArgs e) {
this.ifrm.Attributes [“src”] =“http://www.sample.com/”
}