Change part of images src inside an iframe

Viewed 95

I have a page with an iframe (in the same domain) with lots of images with src="../../imageXX.gif"

I need to change those srcs to "../imageXX.gif"

I´m doing somthing like:

$('iframe').load(function() {
    var src = $(this).contents().find('img').attr('src').replace('/../' ,'/'); 
    $('img').attr('src', src);
})
1 Answers

I think you mean

$('iframe').load(function() {
  $(this).contents().find('img').each(function() {
    let src = $(this).attr('src');
    $(this).attr('src',src.replace('/../' ,'/')); 
  })
})
Related