Search code examples
jqueryclickframeset

jquery click handler inside frame isn't working


I can't make the following code attach a click handler to the elements on the "main" frame. This code is in the frameset definition.

<!-- #include file ="..\include\AuthenticationCheck.asp" --> 
<!-- #include file ="..\include\serverValidate.asp" --> 

<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=iso-8859-1">
<title>Raider Writer Student Roll</title>
<script type="text/javascript" src="../include/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="../include/js/jquery-ui-1.8.4.custom.min.js"></script>

<script type="text/javascript">

    $(function(){//document ready

       $("#main").ready(function () { //The function below executes once the iframe has finished loading

                  $("#main .confirmLink").click(function(e) {
                    alert('hi');

                    });
                });


} );
</script>

</head>
<%
    course_id=request("course_Id")
    if ValidateNumber(course_id)=false then 
        err.raise 8,"Validation: <course_id> is Invalid","<course_id> is: " & course_id
    End if


%>
<%session("currentpage")="tracking"%>

<frameset rows="100,*" border="0">
  <frame name="banner" id="banner" scrolling="no" target="contents" src="rollbanner.asp?course_id=<%response.write(course_id)%>">
  <frameset cols="16%,*" border="5">
    <frame name="contents" id="contents" src="roll.asp?course_id=<%response.write(course_id)%>">



        <frame name="main" id="main" src="../action/helpread.asp?dm=trackingdocs">

  </frameset>
  <noframes>
  <body>
  <p>This page uses frames, but your browser doesn't support them.</p>

  </noframes>
</frameset>


</body>
</html>

Solution

  • Did you try using #main as the context?

    $(".confirmLink","#main").click(function(e) {('hi');});
    

    or changing $("#main").ready(fn) to $("#main").load(fn)