Forum Moderators: open
I am working on a Windows based intranet. We all use IE 6 and soon IE 7.
I have a page that utlilzes an iFrame. I have added jQuery.js, json.js and some javascript functions to this iFrame. I need to handle the click event of the anchor tags in the iFrame but have so far only gotten the message: 'Object Expected' in IE and in FF Firebug 'anchorLink is not defined'. anchorLink is the name of the function I have defined on the iFrame page.
I have tried to add the js code to the main page and to the iFrame with equal, erroneous, results.
My iFrame headers is:
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript"><script src="../../js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="../../js/json.mini.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
function anchorClick(){alert('hi');}
});// end of ready func -- no jquey scripts below this line
</script>
</head>
The anchor element is defined as:
<a href="#" OnClick="anchorClick" class = "enrollment" style="cursor: hand;" id="4">
I have seen where folks have had issues calling the parent from the iframe and vice versa but in my case everything is in the iFrame.
The html tag and js script elements are all being written via response.write in the vb code..if that matters.
If I have left out any important info please request it. As I mentioned I am new to the client-side of things. Thank you for your time!
[edited by: KansasCoder at 6:57 pm (utc) on April 3, 2009]
$(document).ready(function() { that was wrapping my javascript and now the alert is firing.
So I guess the issue is with the jQuery library? I need to use jQuery to make an ajax call to a webmethod so its pretty importantt aht I get this to work this way. It is also how we are doing ajax on our site so I'd like to keep things as consistent as possible.
Any ideas why the Jquery would not be working properly inside an iframe? I tried loading it on the parent page and it made no difference.
Thank you
<script type="text/javascript">
$(document).ready(function() {
$('#iFrameName').ready( function(){
$("a.enrollment").click(function(){alert('clicked');});
});
});line</script>
There's actually quite a bit online about jQuery and iFrames.