jQuery Code Only Fires On Hard Refresh?

Posted by Rob Vanders on Stack Overflow See other posts from Stack Overflow or by Rob Vanders
Published on 2012-11-07T22:18:18Z Indexed on 2012/11/07 23:00 UTC
Read the original article Hit count: 120

The XFBML version of the Facebook Registration plugin only loads HTTPS. I need it to load HTTP so my form does not call a security error mismatch between domains.

I wrote this code to get the SRC and rewrite it with out HTTPS

It works fine on the first load, however on Chrome and Safari it only loads the first time and on HARD refreshes. It does not load on standard reloads or by pressing "enter" on the address bar. Here is the code

$(window).load(function () {
          // Replace HTTPS with HTTP when frame has loaded
       $(".subscribe iframe").each(function(){
        var source = $(this).attr("src");
        //alert(source);
        var sourceNew = source.replace("https", "http"); // change https to http
        alert(sourceNew);
        $(this).attr("src", sourceNew); 
    }); 
}); 

I have .HTACCESS set to disable server cache

<Files *>
Header set Cache-Control: "private, pre-check=0, post-check=0, max-age=0"
Header set Expires: 0
Header set Pragma: no-cache
</Files>

What is causing this to not fire reliably? Thanks

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery