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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:46:35+00:00 2026-05-20T21:46:35+00:00

I am working with Iframes for controlling the elements of iframe by automating it

  • 0

I am working with Iframes for controlling the elements of iframe by automating it from the parent html file.
I was trying to to click the link defined in iframe.html file from the test.html file using function click() on javascript while loading test.html :

Test.html file :

function handleMainOnload(){

    alert("main frame loaded");
    var innerFrame = document.getElementById("frame1");
    alert("hi-1" + innerFrame.ownerDocument.title);
    var innerDocument = frame1.document;
    alert("hi" + innerDocument.title);
    innerDocument.getElementById("input1").value = "Dynamically Inserted Text";
    innerDocument.getElementById("a1").click();
}

<body onload="handleMainOnload();">
<iframe id="frame1" src="iframe.html"/>

iframe.html file :

<a id="a1" href="http://www.google.co.in"> Google.. click</a> 

This achor id = a1 automatically get clicked onload of test.html in IE but doesn’t work on any browser apart from IE. Please help.

  • 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-20T21:46:36+00:00Added an answer on May 20, 2026 at 9:46 pm

    From Javascriptkit.com:

    click() – Executes a click on a element as if the user manually clicked on it. In most browsers, click() only works on form INPUT elements that’s non “submit” or “reset”. It can’t be used to simulate a click on a link or form submit button.

    I have verified that this is the reason why it’s not working for you. Also, I had to change the following line:

    var innerDocument = frame1.document;
    

    to

    var innerDocument = window.frames["frame1"].document;
    

    Will update with a way to do this in jQuery.

    EDIT:

    Here’s how you do it in jQuery. Essentially you bind a click event and then call click() on the element. This simulates the action since there is no standard way of executing clicks on hyperlinks.

    $(document).ready(function() {
            $("#frame1").ready(function () { //The function below executes once the iframe has finished loading
                alert("iframe loaded");
                $('#frame1').contents().find('#a1').click(function() {
                    alert("Hello");
                    $('#frame1').attr('src', $('#frame1').contents().find('#a1').attr("href"));
                    $('#frame1').load();
                });
                $('#frame1').contents().find('#a1').click();
            });
    
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why isn't this script working? $(function() { var isbn = $('input').val(); $('button').click(function() { $(#data).html('<iframe
I working on adding file uploading to my web application. I'm using an iframe
i am trying to open a google search inside an iframe. it was working
I know one can add event listener for window.error. However when working with Iframes,
I'm working on a project that has many iframes that are opened and closed
Possible Duplicate: Are iframes considered 'bad practice'? While working with web developers, I always
I am working on iframes, and I need to show a certain portion of
I am working with iframes, .aspx files and of-course GWT. I have some .aspx
I'm facing a problem while working with iFrames. What I need to do is,
I'm working on a table of links within a site using iframes. I'm wondering

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.