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 8196459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:29:07+00:00 2026-06-07T05:29:07+00:00

Ok so lets say I have a webpage, webpage B. Webpage B has a

  • 0

Ok so lets say I have a webpage, webpage B. Webpage B has a function called “test()”. Now lets say I have another webpage, webpage A. Webpage A has an iFrame with the source of webpage B. How can I execute webpage B’s “test()” function from webpage A?

  • 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-07T05:29:09+00:00Added an answer on June 7, 2026 at 5:29 am

    You cannot ‘directly’ control the javascript of a page within an iframe by any code in the parent page.

    If however you have the ability to change both pages, you can change ‘page B’ to run javascript based on parameters in it’s query string.

    In ‘page A’ Set the iframe src to something like:

    http://mydomain.com/pageb.html?func=myfunc&param=foo&param2=bar

    Then in ‘page B’ run some javascript like this:

    function queryToLookup(query) {
        var lookup= {};
        var params= query.slice(1).split(/[&;]/);
        for (var i= 0; i<params.length; i++) {
            var ix= params[i].indexOf('=');
            if (ix!==-1) {
                var name= decodeURIComponent(params[i].slice(0, ix));
                var value= decodeURIComponent(params[i].slice(ix+1));
                if (!(name in lookup))
                    lookup[name]= [];
                lookup[name].push(value);
            }
        }
        return lookup;
    }
    
    function myTestFunc(p1, p2) {
        alert('param 1 is ' + p1 + ' and p2 is ' + p2);
    }
    
    jQuery(document).ready(function() {
        var params = queryToLookup(location.search);
        switch(lookup['func'])
        {
            case 'myfunc': myTestFunc(params['param1'], params['param2']);
            case 'otherfunc': myTestFunc('someval', params['param1']);
            default: alert('No function requested');
        }
    });
    

    This is of course a very basic example, but can be adapted to do all kinds of crazy stuff. The limitation is that you can’t really pass messages back to ‘page A’, although you ‘could’ (I think) adapt the technique in page A then call top.location = 'pagea.html?message=foo' (like how frame-breaking works).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webpage. I show records from table, lets say, students in my
lets say i have one array a = numpy.arange(8*6*3).reshape((8, 6, 3)) #and another: l
Lets say we have a Company model, that has many Employees And has many
Lets say that you have either URL or a link on a webpage that
Lets say I have a database table called Scrape possibly setup like: UserID (int)
I am creating a webpage..as usual. But I have a problem. Lets say that
Lets say I have a header banner on a webpage I'm about to print.
Lets say we have the following structure in a web page. How can i
Lets say I have a webpage, and all I'm interested is the div with
Lets say we have a class with a property called PetsName. If it is

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.