Transparent p-n heterojunction diodes consisting of n-type ZnO and p-type NiO thin films were prepared on glass substrates by r.f. magnetron sputtering. The structural and optical properties of the n-ZnO/p-NiO heterojunction were characterized by X-ray diffraction (XRD), UV-visible spectroscopy, Hall measurement, and I-V photocurrent measurements. The XRD shows that ZnO films are highly crystalline in nature with preferred orientation along the (0 0 2) orientation. The optical transmittances of ZnO and NiO films are 87% and 80%, respectively. The current-voltage curve of the heterojunction demonstrates obvious rectifying diode behavior in a dark environment. The lowest of leakage current is 7.73×10-8 A/cm2 for n-ZnO/p-NiO heterojunction diode. Upon UV irradiation, it was found that the detector current was increased by more than one order of magnitude. It was also found that the corresponding time constant for turn-on transient was τon = 27.9 ms while that for turn-off transient was τoff= 62.8 ms.