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

  • Home
  • SEARCH
  • 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 5987801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:52:03+00:00 2026-05-22T22:52:03+00:00

I have a script that write a iframe into the page. I want to

  • 0

I have a script that write a iframe into the page.
I want to target a link inside this iframe to have a function.
The problem is:
after the iframe has been written I use this code:

$('#iframe_pin').load(function () {
            $(this).contents().find('a.close').click(function (event) {
                event.preventDefault();
                $('.loaded').fadeOut(fade_time).remove();
            })
        })

and it doesn’t work.
But if I put an alert after the load function, like this:

$('#iframe_pin').load(function () {alert('bla bla');
            $(this).contents().find('a.close').click(function (event) {
                event.preventDefault();
                $('.loaded').fadeOut(fade_time).remove();
            })
        })

it works!

Of course I cannot keep the alert in the code 🙂

Can anyone help me?

  • 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-22T22:52:04+00:00Added an answer on May 22, 2026 at 10:52 pm

    from comments you have something like:

    <div class="loaded">
        <iframe id="iframe_pin" src="abc.html" width="100%" height="100%">
    </div>
    

    so, all you need to do is:

    $("#iframe_pin").load(function() {
    
        // let's get the iframe source
        var iframe = $("#iframe_pin").contents();
    
        iframe.find("a.close").bind("click", function() {
            $(".loaded").fadeOut('slow', function() {
                // now that the FadeOut is finished, let's remove
                $(".loaded").remove();
            });
            return false; // let's prevent to jump in the click
        });
    });
    

    working example at my own space


    Example 2 by creating the <iframe> on the fly


    Example 3 by creating the <iframe> on the fly, removing them and re-creating them

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

Sidebar

Related Questions

I have to write a Matlab script that does this: The input is 2
I have an upload script that write a index.html file, I modified it to
I have to write a bash script that makes lot of things. I'd like
I have one script that sometimes gives Max execution times reached error. This is
I'm not sure how to word this exactly but I have a script that
I have a script that can lookup and output or write my current release
I have a script that repeatedly runs an Ant buildfile and scrapes output into
I have created an iframe code that I want people to use as a
I have a script that constantly segfaults - the problem that I can't solve
I have an HTML page containing an iframe and I am trying to write

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.