You must live in Norway at least half of the time your residence permit is valid for. If you have been issued a residence permit for 1 year, you cannot stay abroad for more than 6 months in total during that year. If you have been given a residence permit for multiple years, you cannot stay abroad for more than a total of 182 days in any 365-day period. If you do, you can lose your residence permit, and you will have to apply for a new residence permit.
If you are going to apply for a permanent residence permit at a later point, you can normally not have stayed outside Norway for more than a total of 7 months in the past three years.