From the time when Yugoslavia was known as the Kingdom of the Serbs, Croats, and Slovenes until the fall of Yugoslavia to the Axis powers of the Second World War, the anthem of the kingdom of Yugoslavia consisted of a combination of the anthems of the various states making up the federation, starting with a few measures from the Serb anthem, continuing with a few lines from the Croat anthem, followed by a portion from a patriotic song of Slovenia at the time (“Naprej zastava slave”, which was composed by the same person that wrote the Serb anthem), and winding up with some lines from the Serbian anthem again. (The lines used from the Serbian anthem do not quite match what is used today by Serbia, as the lines then referred to the king (the text provided refers to “King Peter”, which was used during the reigns of the first Yugoslav king, King Peter I, who reigned until 1921, as well as the last king, King Peter II, whose reign started in 1934), whereas today’s Serbian anthem refers to the Serbian people as a whole.)
Yugoslavia was controlled by the Axis powers in World War II starting in April, 1941, and was continued in use by the government in exile until the nation was liberated in early 1945. The king, still in exile, was formally deposed by the communists who fought against the Germans and controlled the country after liberation, in November of that year.
Special thanks to: Andrea for some of this information.