Masking iframe src doesn't work in Safari

I am loading an iframe in my HTML page. I tried masking iframe src with a javascript function code. It worked on all web browsers except Safari.


Here is my JS code:


function setIframeLoc(nm, value) {
  var endpoint = my_dynamic_custom_url;
  window.frames[nm].location = endpoint;
}

// Setting location for each iframe
$.each(custom_iframe, function(key, value) {
  var myFrame = document.getElementById('iframe-'+key);
  myFrame.setAttribute("class", 'iframe-' + value.iframe_style);
  setIframeLoc("iframe-"+key, value);
});


Here is my HTML code: