In 799 Rijeka was attacked by the Frankish troops of Charlemagne. Their Siege of Trsat was at first repulsed, during which the Frankish commander Duke Eric of Friuli was killed. However, the Frankish forces finally occupied and devastated the castle, while the Duchy of Croatia passed under the overlordship of the Carolingian Empire. From about 925, the town was part of the Kingdom of Croatia, from 1102 in personal union with Hungary. Trsat Castle and the town was rebuilt under the rule of the House of Frankopan. In 1288 the Rijeka citizens signed the Law codex of Vinodol, one of the oldest codes of law in Europe.