Peter Tolan and Leslie Dixon, who wrote the screenplay for this romantic fantasy, may well have based their adaptation on Marc Levy’s novel “If Only It Were True,” but they also owe a major debt to Joseph L. Mankiewicz’s magical 1947 film “The Ghost and Mrs. Muir,” itself based on a book by R.A. Dick. There’s nothing wrong with that, of course; in fact, if you’re going to make a picture of this “Ghost”ly sort, you might as well use the best as your model. And while it’s almost inevitable that “Just Like Heaven” falls far short of its wonderful predecessor, it’s head and shoulders above most of what passes for chick-flick comedy nowadays.

“Muir,” you’ll recall, was about an English widow (Gene Tierney, never lovelier) who moved with her two young children and a housekeeper into a charming seaside cottage that just happened to be haunted by its former occupant, a gruff sea captain (Rex Harrison). Initially the spirit tried to drive the family away, but eventually he became the woman’s protector, penning a memoir that he allowed her to publish under her name to insure her financial security (a literal case of ghost writing) and comforting her after a sleazy novelist (George Sanders) toyed with her affections. The two inevitably fell in love, but it was a romance that clearly couldn’t be realized in this life–a fact that the movie recognized and dealt with in a fashion that made it all the more luminous.

“Just Like Heaven” starts with a similar premise, but instead of the quietly poignant tone of Mankiewicz’s picture–so appropriate to its post-World War II era–it aims for big laughs and an ending more attuned to our instant-gratification society. It also–as might be predicted–involves a gender switch. Mark Ruffalo plays David, a downhearted guy–we later learn he’s a dejected widower–who sublets a San Francisco apartment previously occupied by Elizabeth (Reese Witherspoon), a hard-driving, work-is-everything doctor whom we see involved in a terrible car crash in a the initial minutes. After David moves in, a spectral Elizabeth shows up claiming that he’s invaded her home. He’s understandably nonplussed, and so is she when she realizes that her “body” is an insubstantial bit of mist that can’t even pick up a telephone to call the police. After a bit, though, the two join forces to find out Elizabeth’s identity–she’s forgotten who she is, and her family doesn’t want to discuss her with outsiders–and it turns out that…. Well, it wouldn’t be fair to reveal the twist that the filmmakers have up their sleeve. Suffice it to say that it leads to alternately slapstick and tearjerking episodes involving Dave’s psychologust friend Jack (Donal Logue) and Elizabeth’s sister Abby (Dina Waters), as well as a sex-starved next-door neighbor (Ivana Milicevic) and a clerk at an occult book store (Jon Heder) who has the ability to sense spirits no one else can see. And need one add that as David and Elizabeth work together, they fall in love? And that their romance seems as doomed as that between Mrs. Muir and Captain Gregg?

“Just Like Heaven” isn’t remotely as clever as it aims to be, and it certainly isn’t as affecting as Mankiewicz’s picture. But among fantasies of this kind, which range from the highs of “Blithe Spirit” to the lows of “Kiss Me Goodbye” and cover the whole range in between–the spiffy effort from director Mark Waters (“Freaky Friday,” “Mean Girls”) is better than many. It offers some amusing “Topper”-like moments in the sections early on when only David can see Elizabeth, and a good bit in which David’s body is briefly taken over by the ghost to prevent him from getting drunk (even if it’s an obvious rip-off of “All of Me”). Audiences will probably also enjoy the obvious riffs on movies like “The Exorcist” and “Ghostbusters.” Though the frantic action stuff that takes over in the last act is actually a bit tasteless, it benefits from the participation of Logue, whose grungy charm remains intact. And if Ruffalo and Witherspoon won’t make you forget Tracy and Hepburn, he at least has an affably rumpled presence and she gradually tempers the shrillness of her earlier scenes. Unfortunately, Milecevic overplays the seductive neighbor too much, and Heder (of “Napoleon Dynamite”) is so laid-back that he almost seems comatose. Waters, however, gets the energy and anguish of Elizabeth’s sister reasonably well. And though we could have done without the director’s early-on homage to Robert Zemeckis’ “Forrest Gump” feather sequence (substituting an important sheet of paper blowing in the wind), the technical side of things is smoothly done, with cinematography by Daryn Okada that’s bright without being glaring. But Rolfe Kent’s score can’t help but come up short against the masterful one that Bernard Herrmann contributed to “Muir.”

“Just Like Heaven” may not exactly amount to paradise, but at least it’s not the purgatorial experience many pictures of this sort are.