There's a handy trick you can use to automatically address those issues.
Instead of https:// or http:// in URLs in the page, just use // -- the 'scheme' of http or https will be inserted by the browser based on what was used to load the primary page.