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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:49:05+00:00 2026-05-31T13:49:05+00:00

I am working on how to call a function from an iframe and pass

  • 0

I am working on how to call a function from an iframe and pass data to that function on the parent window. Both the iframe and the parent window are on the same domain. I have a navigation in the iframe that needs be tracked through SCORM and when the user clicks a link in the iframe it should call a function in the the main window and send the currentPage to the function. The links are in an array like this. I need it to call a function called goToPage() in the main window and pass the currentPage that is also on the main window in side the goToPage function. Can anyone help me with this problem? If you could show me in javascript that would be great. Thanks in advance.

function AddNav(links, linkURL) {

var links = new Array();
links[0] = "linkName1";
links[1] = "linkName2";

var linkURL = new Array();
linkURL[0] = "linkURL1.html";
linkURL[1] = "linkURL2.html";

document.write('<ul class="nav">');

for (i=0; i<links.length; i++) {
    document.write('<li class="linkNum">'+links[i].link(linkURL[i])+'</li>');

}
document.write('</ul>');

getElementsByClassName("linkNum")[0].onclick = function () {

currentPage = 0;
var sendData = parent.currentPage;
});

getElementsByClassName("linkNum")[1].onclick = function () {

currentPage = 1;
var sendData = parent.currentPage;
});

}

function getElementsByClassName(linkNum) {
    var elements = document.getElementsByTagName("*");
    var found = [];

    for(var i=0; i < elements.length; i++) {
        if (elements[i].className == linkName) {
            found.push(elements[i]);
        }
    }
    return found;
}
  • 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-05-31T13:49:06+00:00Added an answer on May 31, 2026 at 1:49 pm

    Here’s a sample.

    Parent

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
        <title></title>
        <script type="text/javascript">
            function callFunction(functionName, args) {
                debugger;
    
                var fn = window[functionName];
                if(typeof fn === 'function') {
                    fn(args);
                }
            }
    
            function aFunction(msg){
                alert(msg)
            }
        </script>
    
    </head>
    <body>
    <iframe src="frame.html"></iframe>
    </body>
    </html>
    

    Frame:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
        <title></title>
        <script type="text/javascript">
            window.parent.callFunction('aFunction','aMessage!');
        </script>
    </head>
    <body>
    
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following function that is pulling data from a database. The ajax
I want to call browser window resize method using jquery from with in iframe.
I have a pop-up window from an exiting application that I want to trap
Working with COM interop, I can call a managed function from within unmanaged code.
I'm working on this website, trying to call a function from a C# DLL
I have this function in vb.net that I converted from C# for a project
I want to call a c# function from my javascript function. I have a
I am trying to call a function makeQuery and it's not working, FireBug is
I call the following function with a mouseover event but it's not working. My
Working in a symfony model, I want to override a function and call the

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.