Context. Transmission spectroscopy is a powerful technique for probing exoplanetary atmospheres. A successful ground-based observational method uses a differential technique that uses high-dispersion spectroscopy, but it only preserves narrow features in transmission spectra. Broadband features, such as the remarkable Rayleigh-scattering slope from possible hazes in the atmosphere of HD 189733b as observed by the Hubble Space Telescope, cannot be probed in this way. Aims. Here we use the chromatic Rossiter-McLaughlin (RM) effect to measure the Rayleigh-scattering slope in the transmission spectrum of HD 189733b with the aim to show that it can be effectively used to measure broadband transmission features. The amplitude of the RM effects depends on the effective size of the planet, and in the case of an atmospheric contribution therefore depends on the observed wavelength. Methods. We analysed archival HARPS data of three transits of HD 189733b, covering a wavelength range of 400 to 700 nm. The radial velocity (RV) time-series were determined for white light and for six wavelength bins each 50 nm wide, using the crosscorrelation profiles as provided by the HARPS data reduction pipeline. The RM effect was first fitted to the white-light RV time series using the publicly available code AROME. The residuals to this best fit were subsequently subtracted from the RV time series of each wavelength bin, after which they were also fitted using the same code, leaving only the effective planet radius to vary. Results. We measured the slope in the transmission spectrum of HD 189733b at a 2.5σ significance. Assuming it is due to Rayleigh scattering and not caused by stellar activity, it would correspond to an atmospheric temperature, as set by the scale height, of T = 2300 ± 900 K, well in line with previously obtained results. Conclusions. Ground-based high-dispersion spectral observations can be used to probe broad-band features in the transmission spectra of extrasolar planets, such as the optical Rayleigh-scattering slope of HD 189733b, by using the chromatic Rossiter-McLaughlin effect. The precision achieved with HARPS per transit is about an order of magnitude lower than that with STIS on the Hubble Space Telescope. This method will be particularly interesting in conjunction with the new echelle spectrograph ESPRESSO, which currently is under construction for ESO's Very Large Telescope, which will provide a gain in signal-to-noise ratio of about a factor 4 compared to HARPS. This will be of great value because of the limited and uncertain future of the Hubble Space Telescope and because the future James Webb Space Telescope will not cover this wavelength regime.