Pages

Thursday 7 April 2011

How to modify an IFrame behaviour with jQuery

This post is about how I used jQuery to work out a situation regarding two existing
applications.


The situation is this. We have two applications MainApp and SubApp,
MainApp loads SubApp in a IFrame and passes two out of three querystring parameters.


Now the SubApp was modified to use the third parameter but the MainApp is not currently
passing it and we are not allowed to perform any change to MainApp because it is
a legacy application compiled with framework 1.1. So, what we did was edit the MainApp.aspx
file and add the next lines:
<script language="javascript" src="jquery.min.js"></script>
<script language="javascript" src="querySt.js"></script>
<script language="javascript">
    $(document).ready(function () {
        var $frame = $("#IFrameForSubApp");
        var address = $frame.attr('src');
        address = address + 
                '&ThirdParameter=' + querySt('ThirdParameter');
        $frame.attr(
                'src', address);
    });
</script>
 
That's it, this is how The Code Saved The Day.

No comments:

Post a Comment