In 1397 , Norway was absorbed into a union with Denmark that lasted more than four centuries .