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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:14:26+00:00 2026-05-15T08:14:26+00:00

I have a weird problem and I find no answer on google… I dynamically

  • 0

I have a weird problem and I find no answer on google… I dynamically create and fullfil an iframe with jquery on a page. It works fine withFF and IE, but not with Safari.

The iframe is created but empty (the message “greetings from the iframe !” is missing).
Here is a piece of code to illustrate it :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr-fr" lang="fr-fr" >
 <head>
  <title>iframe</title>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
  <script type="text/javascript">
   $(document).ready(function() {

    var jFrame = $('<iframe id="myiframe" name="myiframe">');
    jFrame.css({'height':'40px','width':'200px'}).appendTo($('#container'));

    $('#myiframe').load(function() {
     jFrame.contents().find("body").html('greetings from the iframe !');
    });

   });
  </script>
 </head>
 <body>
  <div id="container"></div>
 </body>
</html>

I really wonder why the iframe stays empty with Safari. It seems like if “contents()” was not well interpreted…

Any idea ?

  • 1 1 Answer
  • 1 View
  • 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-15T08:14:27+00:00Added an answer on May 15, 2026 at 8:14 am

    Make sure to attach the load event handler before it can possibly fire, like this:

    $('<iframe id="myiframe" name="myiframe" />')
      .css({'height':'40px','width':'200px'})
      .load(function() {
         $(this).contents().find("body").html('greetings from the iframe !');
      })
      .appendTo('#container');
    

    That being said, I’m not positive the load event is required to fire if there was no actual load (your frame has no src), all browsers may be following the spec here, yet still be inconsistent. But…Safari has always been a little “off” with load and ready events, so using the approach above will help that as much as possible. One last note, .appendTo() can take a selector directly 😉

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

Sidebar

Related Questions

I have weird problem, i've placed an google ads on my page and it
I have a weird problem. I create this window, but its blank until i
I have this weird problem with setting up cookies with PHP. Everything worked fine
I have this weird problem where my Google Maps API script doesn't work, no
I have a weird problem I can't solve and can't find any solution to
I have weird problem with this code $('img').hover(function(){ var $cap = $(this).parent().find('.cap'); window.setTimeout(function(){$cap.stop(true,false).animate({bottom:164},500)},500); },function(){
I have weird problem which i find very difficult to reproduce on jsfiddle. Best
I have been experiencing a weird problem that I can't find a solution to.
Ok so I have this weird problem, and I've searched Google many times for
I have a weird problem with a Java Gregorian Calendar: SimpleDateFormat sdf = new

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.