jquery loads content only once
Hello my problem is that whenever i load content to an iframe through javascript and jquery it only loads the first time and then i cannot load anything over it. the function I use is this:
function loadContent(elementSelector, sourceURL) {
$(""+elementSelector+"").attr('src', sourceURL );
}
and i call it through
<li><span><a href="javascript:loadContent('#oPanel', 'http://www.google.com');">Google</a></span></l开发者_开发问答i>
Am I doing something wrong? Thanks!
I've tried to reproduce your problem, but I was not able to. I've create a very simple site with to links and one iframe:
<a class="iframe" href="http://microsoft.com">Microsoft</a>
<a class="iframe" href="http://google.com">Google</a>
<iframe id="oPanel"></iframe>
and 4 lines of unobstrusive JavaScript to load those links within the iFrame:
$('a').click(function(){
$('#oPanel').attr('src',$(this).attr('href'));
return false;
});
And it's working as expected. You can try it here: http://jsfiddle.net/jQncy/
精彩评论