FOR YEARS parents have been trying to discourage their children from watching too much television. Now along comes a movie that may do the job for them. Steven Spielberg's "Poltergeist," opening here and throughout the country on June 4, shows the little kiddies what can happen to them if they dare dally too long at the tube.

If they dally too long at the tube, especially late at night, ghosties might come out of the set and gobble them up and pull them into the Electron Otherworld. At least, that's what happens to a little girl parked in front of a Sony in this sensationally scary, yet essentially friendly, new movie, destined to be one of the summer's biggest hits.

Of course that isn't the moral of the film--"Don't watch TV." But it certainly offers a new meaning for the word "ghosts" in relation to television (technically, a ghost is a double image, a shadow on the screen) and posits a novel explanation of how spooks get into a house in order to haunt it. They creep in late at night, after a TV station signs off with the National Anthem and the screen turns to glowing snow. "They're here," the little girl tells her parents. "Who?" they ask. "The TV people," she says.

For Hollywood, this is the latest in a series of movie pokes at television, with which it always has had a love-hate relationship, except in films of the the late '40s and early '50s, when it was more of a hate-hate relationship because it looked as though TV would kill the movies and Americans would never leave their homes again.

It was common in pictures of that time to take a swipe or two at the idiot child known as television (still an idiot, but now an adolescent). In a cheapie revue film called "Variety Time" made by Jack Paar during his short-lived movie career, he hosts a segment in which TV is lampooned as a clunky technical botch that puts out squiggly, fun-house-mirror pictures. In a few years television would rescue Paar from grade-Z Hollywood films like that one and make him a national fixture until the mid-'60s.

David Parker, of the Motion Picture Division of the Library of Congress, thinks one reason TV was ridiculed in films of this period was that on the West Coast, viewers saw not the live shows seen by the rest of the country, but crude kinescopes made for airing in the Western time zone.

"Those kinescopes looked about as bad as television can look," says Parker. "People saw distorted faces and banana noses and everything else. So of course they thought television was something that would never last. Boy were they wrong."

Meanwhile, Bob Hope was on the radio telling jokes like, "You know what television is, don't you? That's smog with knobs." At the end of his film "Son of Paleface," Hope has just spent a few years waiting for his wife, Jane Russell, to get out of prison; when she does, she is accompanied by several mysteriously begotten children. Hope looks into the camera and sneers, "Let's see them top that on television."

It wouldn't be long before Hope would become more of a star on TV than he had been in any other medium.

When it grew obvious that TV was going to hang around awhile ("It's just a fad, like flagpole sitting," Lucy once joked to Ricky on "I Love Lucy"), movies stopped kidding about the technical quality of it and went after the vulgarity of it, like in the underrated MGM musical "It's Always Fair Weather," in which three pals are reunited on a mawkish program called "Midnight With Madeleine," patterned after such cringe-inducers of the time as "This Is Your Life," "It Could Be You" and "Strike It Rich."

Movies like "The Great Man" and "A Face in the Crowd" took angry swipes at TV's power to turn nobodies into demagogues. Michael Clark, director of programming for the American Film Institute Theater here, recalls that in the Douglas Sirk weeper "All That Heaven Allows," TV got the unusual role of sexual surrogate. "Jane Wyman's kids kept saying to her, 'Why don't you get a TV set?' " Clark says, "and finally they give her one themselves to get her to stay away from Rock Hudson." This was the '50s when, according to the film, an older woman's romance with a younger man could rend a small town asunder.

Former TV writer Herb Gardner wreaked exquisite revenge on television with his brilliant 1965 comedy "A Thousand Clowns," in which TV inanity was epitomized by the character of Chuckles the Chipmunk (Gene Saks), a motheaten old ham playing video uncle to unsuspecting tots. Ironically, maybe, the film version of Gardner's play was directed by Fred Coe, who produced many of the best-remembered live dramas from TV's Golden Age.

In recent years, filmmaker attacks on television have ranged from all-out frontal assaults like "Network" to blitheringly indecipherable hogwash like the current "Wrong Is Right." John Schlesinger has lampooned the banality of TV in films like "Darling" and "Midnight Cowboy." In "The China Syndrome" and "Eyewitness," the heroines were rigorously over-achieving TV newswomen--a new cliche' for films. And in the forthcoming sci-fi feature "Videodrome," directed by David Cronenberg, cable TV is the villain, piping in ghastly atrocities to horrified Canadian TV viewers.

Still, "Poltergeist" may be the most audacious speculation on the possible deleterious effects of television yet seen in a movie. At the end of the film, when the harassed father of the family throws a TV set out, the audience at a sneak preview here in Washington cheered. Of course, they all hate television, right? And someday, they'll be watching "Poltergeist" again, this time on TV.

Movies can take all the pokes at television they want, but many are now made with TV technology as part of the process, and almost all of them now have sales to pay-TV and free-TV written into their budgets; in a classic case of kissing the hand that beats you, CBS paid almost as much for the rights to show "Network" as it cost to make the movie. The movies can scoff and jeer, and even say TV provides a pipeline for fiendish thingies into the American home, but let's face it: Sooner or later, everything gets turned into Television.