Replacing one derailleur with another type
The derailleur you linked is compatible.

In general, Shimano shifters for 9 speeds or less for off-road series and 10 speed or less for road series are interchangeable if the mounting scheme fits. 7-speed cassette is narrower than 8-speed, but the derailleur probably has enough room for adjustment to fit the wider cassette (edit: actually, it was 7-8 so it definitely should work). 

The derailleurs for more speeds require a corresponding shifter to work correctly. Derailleurs from other brands are also not compatible without tricks with adapters, with the exception of some old SRAM units specifically marketed as Shimano compatible.