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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:18:28+00:00 2026-06-12T19:18:28+00:00

Sample code: <!DOCTYPE html> <html> <head> <title></title> </head> <body> <iframe name=iframe_a onload=alert(‘Thanks for the

  • 0

Sample code:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<iframe name="iframe_a" onload="alert('Thanks for the visit!');"></iframe>
<a href="http://www.example.com/" target="iframe_a">Go!</a>
</body>
</html>

I’d like to see the alert message after clicking on the link and when the iframe finishes loading. But now it appears on the initial page load, too. How can I achieve it so it works in IE8+?

Just came up with a simple solution:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<iframe id="iframe_a" name="iframe_a" onload="if(this.className=='active'){alert('Thanks for the visit!');};"></iframe>
<a href="http://www.example.com/" target="iframe_a" onclick="document.getElementById('iframe_a').className='active';">Go!</a>
</body>
</html>
  • 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-12T19:18:29+00:00Added an answer on June 12, 2026 at 7:18 pm

    There’s no (sane) way to prevent onload of an iframe when it’s in the DOM. Adding onload to iframe just before you’re loading it should fix your issue:

    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    </head>
    <body>
    <iframe id="myIframe" name="iframe_a"></iframe>
    <a href="#" onclick="$('#myIframe').load(function() {alert('Thanks for the visit!');}); $('#myIframe').attr('src','http://www.example.com/')">Go!</a>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sample code: <!DOCTYPE html> <html> <head> <title>test</title> <script language=javascript type=text/javascript> function init() { var
Sample code: <!DOCTYPE html> <html> <head> <title></title> <style> span {display:none;} </style> <script src=https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js></script> <script>
This is the code I have: <!DOCTYPE html> <html> <head> <title><%= title %></title> <%=
This sample code won't pass w3c validator. <?xml version=1.0 encoding=UTF-8 ?> <!DOCTYPE html PUBLIC
my sample code is here include 'simple_html_dom.php'; function get_all_links($url){ global $host; $html = new
Is it possible to use HTML Tidy to just indent HTML code? Sample Code
I'm learning dhtml using google's sample http://code.google.com/edu/ajax/tutorials/samples/dhtmltest.html however, when i add below doctype dtd
In this google map sample: http://code.google.com/apis/maps/documentation/javascript/examples/streetview-simple.html If the user dropped the little guy far
Why this sample of code doesn't work on IE7. Where is the problem? Thanks.
Sample Code: var Day = Ember.Object.extend({ date:null, activities:null, // is set to an Em.ArrayProxy

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.