In this paper, we introduce a new online motion retargeting technique to generate natural locomotion of walking on slopes and stairs using only a single captured reference motion. An inverse-kinematics solver is developed to generate poses satisfying smooth trajectories of positional and rotational constraints for feet and hands. By considering the rotations of the pelvis and upper body, our technique is able to produce natural poses without knee-popping artifacts.