简体   繁体   中英

Iframe not working with the src attribute set in Mozilla

I have an iframe on a page called Test.aspx that points to a url src="IframeTest.aspx" which is located in the same directory but i keep getting an error that says:

HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

EDIT

The iframe seems to display in IE9 but not in Mozilla, i am dynamically and statically adding two iframes to test and found that the two iframes work in IE9 but not in Mozilla at all.

EDIT

This is my aspx page

<%@ Page Language="VB" EnableEventValidation="false" AutoEventWireup="false" CodeFile="mainpage.aspx.vb" Inherits="mainpage" %>
<%@ Register TagPrefix="ChatBeatsWebControls" Namespace="ChatBeats.WebControls" Assembly="ChatBeats.WebControls" %>

<script src="js/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="jquery/JqueryUI/js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="js/ui.multidraggable.js" type="text/javascript"></script>
<script src="js/chatbeats.dragdrop.js" type="text/javascript"></script>
<script src="js/mainpage.js" type="text/javascript"></script>
<script src="js/generic.js" type="text/javascript"></script>
<script src="js/chatbeats-player-embed.js" type="text/javascript"></script>
<script src="js/swfobject.js" type="text/javascript"></script>
<script src="js/treeview.js" type="text/javascript"></script>
<script src="js/swfobject2.js" type="text/javascript"></script>
<script type='text/javascript' language='javascript' src='http://us.js2.yimg.com/us.js.yimg.com/lib/flash/swfobject/1.0/swfobject.js'></script>
<script src="js/jquery.address.js" type="text/javascript"></script>

<%-- MediaCenter Content Flow --%>
<link href="images/mainpage/mediacenter/contentflow.css" rel="stylesheet" type="text/css" />
<link href="images/mainpage/mediacenter/contentflow_src.css" rel="stylesheet" type="text/css" />
<%--<link href="images/mainpage/mediacenter/contentflow_src.css" rel="stylesheet" type="text/css" />
<link href="images/mainpage/mediacenter/ContentFlowAddOn_DEFAULT.css" rel="stylesheet" type="text/css" />--%>

<script src="images/mainpage/mediacenter/contentflow.js" type="text/javascript"></script>
<script src="images/mainpage/mediacenter/contentflow_src.js" type="text/javascript"></script>
<%--<script src="images/mainpage/mediacenter/contentflow_src.js" type="text/javascript"></script>
<script src="images/mainpage/mediacenter/ContentFlowAddOn_DEFAULT.js" type="text/javascript"></script>--%>
<script src="js/jquery.dynamicCarousel.js" type="text/javascript"></script>
<link href="styles/jquery.dynamicCarousel.css" rel="stylesheet" type="text/css" />

<script src="js/jquery.thslide.js" type="text/javascript"></script>

<script src="js/jquery.jCarouselLite.js" type="text/javascript"></script>


<link href="styles/ImageCarousel.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.ImageCarousel.js" type="text/javascript"></script>

<script src="js/autoresize.jquery.js" type="text/javascript"></script>
<script src="js/jquery.flip.js" type="text/javascript"></script>
<script src="js/slimScroll.js" type="text/javascript"></script>

<script src="js/genCheckBox.jquery.js" type="text/javascript"></script>

</head>
<body oncontextmenu="return false;">
<form id="form1" runat="server">
<div id="mainpagecontainer">
    <ChatBeatsWebControls:TransparentBackgroundControl ID="TransparentBackgroundControl1" runat="server"></ChatBeatsWebControls:TransparentBackgroundControl>
    <ChatBeatsWebControls:MainPageControl ID="MainPageControl1" runat="server"></ChatBeatsWebControls:MainPageControl>
    <%--<ChatBeatsWebControls:PlaylistMediaDisplayDialogControl ID="PlaylistMediaDisplayDialogControl1" runat="server"></ChatBeatsWebControls:PlaylistMediaDisplayDialogControl>--%>
    <ChatBeatsWebControls:Page.LibraryOption.AddVideoMediaControl ID="AddVideoMediaControl1" runat="server"></ChatBeatsWebControls:Page.LibraryOption.AddVideoMediaControl>
    <ChatBeatsWebControls:Page.LibraryOption.AddPlaylistControl ID="AddPlaylistControl1" runat="server"></ChatBeatsWebControls:Page.LibraryOption.AddPlaylistControl>
    <%--<ChatBeatsWebControls:Page.Content.MediaSelectedOptionsControl ID="MediaSelectedOptionsControl1" runat="server"></ChatBeatsWebControls:Page.Content.MediaSelectedOptionsControl>--%>
    <ChatBeatsWebControls:Page.Content.AddChannelControl ID="AddChannelControl1" runat="server"></ChatBeatsWebControls:Page.Content.AddChannelControl>
    <ChatBeatsWebControls:Page.Content.AddChatRoomControl ID="AddChatRoomControl1" runat="server"></ChatBeatsWebControls:Page.Content.AddChatRoomControl>
    <ChatBeatsWebControls:Page.Content.AddMediaPlaylistControl ID="AddMediaPlaylistControl1" runat="server"></ChatBeatsWebControls:Page.Content.AddMediaPlaylistControl>
    <ChatBeatsWebControls:Page.Content.EditMediaPLaylistControl ID="EditMediaPLaylistControl1" runat="server"></ChatBeatsWebControls:Page.Content.EditMediaPLaylistControl>
</div>
</form>
<div>
    <iframe id="iframetestpages" name="iframetestpages" src="IframeTest.aspx">    </iframe> 
</div>
</body>
</html>

IframeTest.aspx Page

  <%@ Page Language="VB" AutoEventWireup="false" CodeFile="IframeTest.aspx.vb" Inherits="IframeTest" %>

  <!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>
    <input type="file" />
  </div>
  </form>

 </body>
  </html>

Dynamically added Iframe using Vb.Net

 Me.Controls.Add(New IFrame("", "iframetestpage", "iframetestpage", "IframeTest.aspx"))

Iframe Class

  Option Explicit On

Option Strict On

Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Imports System.Web.UI Imports System.IO Imports System.Text Imports API.HTML.Controls.Enums Imports System.Text.RegularExpressions

Namespace HTML.Controls Public Class IFrame Inherits HtmlGenericControl

    Public Sub New(ByVal CSSClass As String, ByVal name As String, ByVal id As String, ByVal src As String)
        Me.New()
        Me._CSSClass = CSSClass
        Me._Name = name
        Me._ID = id
        Me._Src = src
    End Sub

    Public Sub New()
        MyBase.New("iframe")
    End Sub

    Private _Src As String
    Private _CSSClass As String
    Private _Name As String
    Private _ID As String

    Private ReadOnly Property Src() As String
        Get
            If Me._Src Is Nothing Then
                Return String.Empty
            End If
            Return Me._Src
        End Get
    End Property

    Private ReadOnly Property CSSClass() As String
        Get
            If Me._CSSClass Is Nothing Then
                Return String.Empty
            End If
            Return Me._CSSClass
        End Get
    End Property

    Private ReadOnly Property Name() As String
        Get
            If Me._Name Is Nothing Then
                Return String.Empty
            End If
            Return Me._Name
        End Get
    End Property

    Private ReadOnly Property ID() As String
        Get
            If Me._ID Is Nothing Then
                Return String.Empty
            End If
            Return Me._ID
        End Get
    End Property

    Private Sub IFrame_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        Me.AddAttributes()
    End Sub

    Private Sub AddAttributes()

        If Me.CSSClass <> "" Then
            Me.Attributes.Add("class", Me.CSSClass)
        End If

        If Me.Src <> "" Then
            Attributes.Add("src", Me.Src)
        End If

        If Me.Name <> "" Then
            Attributes.Add("name", Me.Name)
        End If

        If Me.ID.Length > 0 Then
            Attributes.Add("id", Me.ID)
        End If
    End Sub

End Class
End Namespace

I created a test site to try and reproduce your error that includes the following:

Test.aspx

<iframe src="IframeTest.aspx" style="border:1px solid black"></iframe>

IframeTest.aspx

<p>Hello World!</p>

Without your exact code and not knowing your file paths I am unable to reproduce your error.

I would recommend however, to create these pages in .HTML in the same directory with only an iframe in test.html and a <p>Hello World</p> in IframeTest.html . This might help you to realize where the problem may lie by stripping down your code to nothing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM