I am using jQuery and Ruby On Rails.
I have an ajax call $.get() which renders a piece of html containing a iframe
I want to modify the iframe in order to make sure the <a> links open in a new window.
To do this I have added an onload to the iframe definition:
<iframe id="iframe_message_<%= message.id %>" class="iframe_message" name ="iframe_message_<%= message.id %>" width="100%" frameborder="0" src="<%= message.attachments.body_html.first.document.url %>" onLoad="autoResize('iframe_message_<%= message.id %>');">
the autoResize function is defined in the html rendered by the ajax call and contains:
$(".iframe_message").ready(function () {
$('a', frames[id].document).attr('target','_blank');
});
This works fine in IE, Safari but I have a problem with firefox where it works the first time the $.get() is called by a mouse click but not on the following click (the <a> tags are not modified).
I thought on a caching issue and replaced the $.get() by the $.ajax() with cache:true but I still have the same behaviour.
Any ideas on what could be the problem?
I went of the jQuery website and looked at the .content description
and my “working” code is
where
"#"+idis the id of my iframe.