Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8564123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:07:30+00:00 2026-06-11T17:07:30+00:00

I have a mainframe and a iframe: I pass a function beforeIframe to mainFrame.

  • 0

I have a mainframe and a iframe:

  1. I pass a function beforeIframe to mainFrame.
  2. mainFrame changse URL of beforeIframe to changedIFrame.
  3. When changedIFrame is loaded then execute the anonymous function.

The code below is what I want to do:

mainFrame.jsp

function randerLeftMenu(callBack) {
    $("#ifrm").attr("src", "<ui:context />/changedIframe")
    if(callBack) {
        $("#ifrm").load(function() { callBack(); });
    }
}

beforeIframe.jsp

(I have to manipulate DOM object.)

parent.randerLeftMenu(function() {$("#docType").val("aaa"); });

changedIframe.jsp

<input type="text" value="testVal" id="docType" class="input width2">

I’ve tried many things, but I can’t achieve that.

mainFrame

function randerLeftMenu(callBack) {
    if(callBack) {
        $("#ifrm").load(function() {
            with(this.contentWindow) { callBack(); }
            callBack.apply(this);
            eval(callBack());
            callBack.call(this);
            $.proxy(callBack(),this.contentWindow);
        });
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:07:31+00:00Added an answer on June 11, 2026 at 5:07 pm

    In your example, the $ you are including within the randerLeftMenu call out of “beforeIframe.jsp” will always be scoped to the context from which it is called. Only the this variable can be dynamically bound to a different scope. You ought to be able to get around this though by passing the function as a string (or rely on Function‘s toString() method) and evaluating the string dynamically.

    Updated to include working example (tested Firefox and IE):

    function randerLeftMenu(callBack) {
        $("#ifrm").attr("src", "<ui:context />/changedIframe");
        if(callBack) {
            $("#ifrm").load(function(e) {
                try {
                    // This script injection and setTimeout is only necessary
                    //  if you don't want to change the iframe source to add jQuery;
                    //  otherwise, you only need the eval().
                    var script = document.createElement('script');
                    script.src = "http://code.jquery.com/jquery-latest.js";
                    e.target.contentWindow.document.body.appendChild(script);
                    setTimeout(function () {
                        // var evalStr = 'e.target.contentWindow.eval(\'('+callBack.toString().replace(/\n/g, ' ')+')()\')'; // You can pass the function and convert to a string for Firefox, but IE of course doesn't support it, so you will need to pass the function as a string
                        var evalStr = 'e.target.contentWindow.eval(\'('+callBack.replace(/[\r\n]/g, ' ')+')()\')';
                        eval(evalStr);
                    }, 500);
                }
                catch(e) {
                    alert(e);
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a Japanese client that has source code in COBOL on an mainframe.
In my javascript code I load a jsp page in an iframe and pass
I have an iframe called mainframe you click a link inside the iframe, and
I have an input box for user to enter any url. Then I would
i have a mainFrame that contains panel. i want in this panel a thread
Ok. I have a mainframe which contains two containers. One contains my wizard-alike buttons
I have 2 classes, mainFrame and panel. By clicking the button on mainFrame I
I have the following: $(document).ready(function() { var myIframe = document.getElementById('myIframe'); var element = myIframe.contentDocument.createElement('script');
I have an IFRAME that should be filled with content from JavaScript. Had the
I have a web page that has a DIV and an IFRAME. When a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.