2012-04-10 97 views
0

我在我的asp网页中有一个iframe,我从代码后面动态加载url。 但在加载我的网址在iframe中时,它并未在Chrome和Safari浏览器中打开。 它在IE和FF中完美工作。Url不在谷歌浏览器和Safari中的iframe中加载

任何人都可以帮我解决这个问题。示例代码如下:

<%@ 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

让我们看看后面的代码。 – 2012-04-10 14:07:39

回答

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> 
+0

我很好奇,是否真的有一个浏览器不支持iframes :)? – YvesR 2012-04-10 14:21:56

+1

@YvesR:好奇是一件好事。在闲暇时阅读http://en.wikipedia.org/wiki/Site-specific_browser :) – naveen 2012-04-10 14:58:08

0

尝试将此添加到Page_Load事件

保护无效的Page_Load(对象发件人,EventArgs的) {

this.ifrm.Attributes [ “SRC”] =“HTTP ://www.sample.com/“

}

相关问题