Magic, much like ranged, is another combat skill that requires no combat to get 99 in. However, unlike ranged, magic can actually be trained through combat, but it is not recommended as there are much faster ways.
Because of the flaws in the Magic skill, there is no level or rune requirement to cast teleportation spells, but they still give experience. This allows players with a low magic level to level up extremely quickly with no effort aside from clicking.
All you should do to get 99 magic is click the "T" teleport (trollheim I think) in the regular spellbook over and over until you reach 99. You will level up extremely quickly at lower levels, and also fairly quickly at higher levels (90+). If you want, you can use an autoclicker to help you, but as I mentioned in the ranged guide, do this at your own risk.