iframe onload event not firing in safari and chrome


iframe onload event not firing in safari and chrome...

The onload event does not fire when page is loaded. TabPanel tp_1 should be populated and not blank.  

You can see the content if you hit TabPanel tp_3 and then TabPanel tp_1 again.

How can I make this work in safari and chrome.  It does work in firefox and IE.

ps: TabPanel tp_2 has a different unrelated problem in the src page, I am working on it currently.

Thank You Sam


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Scratch_Debug.aspx.cs" Inherits="WebApplication1.Debug.Scratch_Debug" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <style type="text/css">
        .IframeSize {
            height: 850px;
            width: 100%;
    <form id="form1" runat="server">
        <ajaxtoolkit:toolkitscriptmanager ID="ToolkitScriptManagerManage" runat="server">        </ajaxtoolkit:toolkitscriptmanager>
        <ajaxtoolkit:TabContainer ID="tc_1" runat="server" ActiveTabIndex="0"  Width="100%" Height="900px">

            <ajaxtoolkit:TabPanel ID="tp_1" runat="server" HeaderText="tp_1" OnClientClick="LoadIframe('Iframe_1', 'Message_Debug.aspx')">

                <HeaderTemplate>tp_1                </HeaderTemplate>

                    <%--iframe onload event not firing in safari and chrome--%>
                    <iframe id="Iframe_1" src= 'about:blank' class="IframeSize" onload="LoadIframe('Iframe_1', 'Message_Debug.aspx')">            </iframe>


            <ajaxtoolkit:TabPanel ID="tp_2" runat="server" HeaderText="tp_2" OnClientClick="LoadIframe('Iframe_2','Locks_Debug.aspx')">
                <HeaderTemplate>tp_2               </HeaderTemplate>
                    <iframe id="Iframe_2" src= 'about:blank'  class="IframeSize">             </iframe>

            <ajaxtoolkit:TabPanel ID="tp_3" runat="server" HeaderText="tp_3" OnClientClick="LoadIframe('Iframe_3','TreeView.aspx')">
                <HeaderTemplate>tp_3                </HeaderTemplate>
                    <iframe id="Iframe_3" src= 'about:blank'  class="IframeSize">             </iframe>
    <script type="text/javascript">
        function LoadIframe(Iframe, url) {
            alert("@ LoadIframe -->" + Iframe + "<--" + "\n url -->" + url + "<--");

            var ele = document.getElementById(Iframe);

            //if undefined this is the first time, so load Iframe and initialize parameter so it dosen't happen again
            if (ele.IsLoaded == undefined) {
                alert("Iframe.IsLoaded = undefined ");

                document.getElementById(Iframe).src = url; //"Message_Debug.aspx";

                ele.IsLoaded = true; //create and set custom attribute
                //alert("Iframe.IsLoaded set -->" + ele.IsLoaded + "<--");
            else {
                alert("Iframe.IsLoaded is defined "); //do nothing...

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SamCashAuthor Commented:
Move the setting of the iframe src= to body onload...

<body> change to
<body onload="LoadIframe('Iframe_1', 'Message_Debug.aspx')">

<iframe id="Iframe_1" src= 'about:blank' class="IframeSize" onload="LoadIframe('Iframe_1', 'Message_Debug.aspx')"> </iframe> change to
<iframe id="Iframe_1" src= 'about:blank' class="IframeSize" >            </iframe> 

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.