Iframe src caching issue on firefox

前端 未结 4 898
借酒劲吻你
借酒劲吻你 2021-02-19 06:13

I have an iframe element with a random scr attribute. When I do refresh the page every time, the iframe should load the page with different query parameters based on the src att

4条回答
  •  旧时难觅i
    2021-02-19 07:08

    We had the same problem with firefox caching the iframe src and disabling the cache on the original page as well as the iframe page did not help. We put the following code (jQuery code) in the onload function of iframe:

    $(parent.document).find("iframe").each(function() {
        // apply the logic only to the current iframe only
        if(this.contentDocument == window.document) {
           // if the href of the iframe is not same as 
           // the value of src attribute then reload it
          if(this.src != location.href) {
            this.src = this.src;
          }
        }
    });
    

提交回复
热议问题