If you want to allow your cat outside in the privacy of your backyard, you can purchase or build a specially designed fence or enclosure that will prevent your cat from leaving the yard. However, a fence may not prevent animals from entering your yard, so you should always be present when you allow your cat this opportunity. And be sure to cat-proof the yard by checking that the fence has no escape routes and by making toxic plants, garden chemicals, and other dangerous objects inaccessible.
Several companies manufacture ready-made cat confinement systems that enable your feline to experience the great outdoors yet remain safe. Other companies and organizations have developed similar plans for do-it-yourselfers. Here's a sampling.