Winter is coming. I plan to stick soft polyethelene foam on window glass for thermal insulation. Last time I use Styrofoam glue, and it is a disaster. It is hard to remove it. It take hours with alcohol and box cuter. Is there any proper material for the job? The house is rented. In future I will have to remove it. I am looking for a glue strong enough to keep polyethelene foam and glass together, removable in future, and leave no gap. I tried gap before, if foam and glass has a gap between, moisture condenses and molds. I wonder is 3M 77 spray adhesive will do the job? It sticks like a 3M post-it. Or is there any alternative? Thank you!
Small dabs of clear silicone caulk. You'll have to secure the foam while the silicone cures (maybe 4 hours), but it'll hold very well and will be a breeze to remove and clean up. You could use masking tape or lean a broom against it. Start with pea-sized dabs, and leave them round until the foam presses into them. Keep them away from the window frame for easier removal.
Double-sided foam tape. This would be fast and easy, but it would leave a small gap against the glass. This just means that you'll need to seal the foam well at the edges. Rope caulk could help with that. A few squares around the perimeter should do nicely, or you could seal the entire edge.
Because this application of polystyrene has been so problemmatic, have you considered thermal liners/draperies, or applying long sections of large sized bubble wrap, which only require spritzing the glass lightly with water to cause the bubble wrap to tightly adhere to the window panes? Either remedy should afford better insulation with less work.
Glass is hard to glue to, since it is such a glossy surface. Generally effective glues will be the "sticky forever" kind that behave like gum.
The problem is, UV light will be your enemy. It is going to modify almost any glue you could use, into a brittle, deteriorated haze of a mess to remove from the window.
One important concept about insulation is that narrow air gaps are not your enemy. Consider how a double-pane window works. When airspace is narrow enough (less than 1 inch), it stops convection from operating in that space. The air actually becomes a pretty good insulator. Another insulation that uses that concept is fiberglas; the strands don't insulate, they just add friction to keep the air from moving freely. The air does the insulating; that's why compressing fiberglas hurts its insulation value.
As such, you should not be afraid at all to leave a 1/2" to 1" gap. Trying to conform the foam tightly to the window and frame is actually working against yourself.
That opens the possibility of using rigid products such as XPS or polyiso foam, which simply span the window, and are affixed at the edges. They have considerably greater insulation value than any of the sheet foam you have been looking at.
That said, don't forget about the impact of window air leakage. If the window is drafting, it could push the air through that intentional gap, defeating its purpose. So address any leaky window gaskets. Keep in mind old windows weren't built to be drafty; they were built with competent seals, whose maintenance has since been neglected.
This is an ideal case for hot glue. It holds plenty strong, won't break down much in UV conditions, and is cheap and widely available. Clean the window and foam before applying for best adhesion.
You can probably just yank the foam off when you move, but if it's vacuumed on good, a hair dryer can be blown on both sides to heat it enough to soften the grip. Once the foam is removed, any globs of leftover hotglue will easily pull or scrape off without leaving something messy that needs solvents to cleanup.