Yes, portable solar panels can work through windows, but their efficiency is significantly reduced due to the window glass absorbing and reflecting some of the sunlight. Moreover, the type of glass on the window also plays a role in the panel's efficiency, and tinted windows can decrease the amount of solar energy that reaches the panel, further reducing its performance.
Thus, it is generally recommended to use them outdoors in direct sunlight for maximum efficiency. Moreover, if you do need to use solar panels through windows, in order to counter the reduced efficiency, it might be in your best interest to invest in a portable power station to store the energy for later uninterrupted use.