Given the widespread clinical demand, addressing irregular cranial bone defects poses a significant challenge following surgical procedures and traumatic events. In situ-formed injectable hydrogels are attractive for irregular bone defects due to their ease of administration and the ability to incorporate ceramics, ions, and proteins into the hydrogel. In this study, a multifunctional hydrogel composed of oxidized sodium alginate (OSA)-grafted dopamine (DO), carboxymethyl chitosan (CMCS), calcium ions (Ca 2+ ), nanohydroxyapatite (nHA), and magnesium oxide (MgO) (DOCMCHM) was prepared to address irregular cranial bone defects via dynamic Schiff base and chelation reactions. DOCMCHM hydrogel exhibits strong adhesion to wet tissues, self-healing properties, and antibacterial characteristics. Biological evaluations indicate that DOCMCHM hydrogel has good biocompatibility, in vivo degradability, and the ability to promote cell proliferation. Importantly, DOCMCHM hydrogel, containing MgO, promotes the expression of osteogenic protein markers COL-1, OCN, and RUNX2, and stimulates the formation of new blood vessels by upregulating CD31. This study could provide meaningful insights into ion therapy for the repair of cranial bone defects.