Ananth Vyas

Ananth Vyas

  • NA
  • 1
  • 0

Event handler not fired for iframe when loaded on clicking hyperlink inside the iframe.

Apr 9 2010 12:47 AM
Hi,
   I need to have an even handler such that when the i frame is loaded with an url, i should be able to access it.... 

but my problem is that i associated all available events for the iframe to a single function which basically displays an alert box with the url. It works if i load the iframe with the url externally i.e. when i load it in code behind.. 

but if i click a hyperlink present inside the frame and the frame loads with that page, it does not fire any event... 

my iframe definition is as below :

<iframe id="frame1" scrolling="auto" runat="server" ondatabinding="frame1_Load" oninit="frame1_Load" onload="frame1_Load" onprerender="frame1_Load" frameborder="0">
</iframe>

and frame1_Load function is as below....

    protected void frame1_Load(object sender, EventArgs e)
    {
       Response.Write("<script>alert('"+frame1.Attributes["src"]+"')</script>");
    }

How do i access the URL in such situations?? pl do help if anyone has a clue on this.... :(

Thanks !