All submit buttons inside iframe
Hi Guys,
I 'm currently working with an existing asp.net application that uses iframe to load and show aspx pages. My PM doesn't like the inner scrollbars so i calculate the iframe height dynamically and remove the scrollbars and set the height. I do this on the iframe load event like this:
Note:ifmain is the id for the iframe
-
$(function() {
$("#ifmain").bind("resize load", sizeIFrame);
});
function sizeIFrame(plusHeight) {
if (isNaN(plusHeight))
plusHeight = 0;
window.setTimeout("sizeIFrameHeight(" + plusHeight + ");", 100);
}
function sizeIFrameHeight(plusHeight) {
var helpFrame = $("#ifmain");
var innerDoc = (helpFrame.get(0).contentDocument) ? helpFrame.get(0).contentDocument : helpFrame.get(0).contentWindow.document;
if (innerDoc.body) //sometimes body object is null. Handling this to suppress javascript errors
helpFrame.height(innerDoc.body.scrollHeight + plusHeight + 35);
else
helpFrame.height(600 + plusHeight + 35);
}
But when internall in the aspx, if submit button is clicked, i see content partially cropped. As a fix to this issue, i invoke the iframe javascript function to resize the height like this:
-
window.parent.sizeIFrame(0);
But it is always difficult to open each page and bind this javascript call. What i would like to achieve using jQuery is to get all the submit buttons in the iframe and bind this javascript function. I tried the following ways but not successful. Can anyone shed some light and help solve this issue.
-
alert($("#ifmain form body :submit").length); //returned 0
alert($("#ifmain form body").length); //returned 0
alert($("#ifmain form").length); //returned 0
alert($("#ifmain").length); //returned 1
alert($("#ifmain").find("input[type=submit]").length); //returned 0