Now I want the same funtion in javascript. Is there any way to make the frame which uses in the above scripts that the url people open it doesn't change when it already redirect to the another url address?

Yep,
indeed frames should be used. When you are using frames the url of that frameset will show in the location, and you can change the location of each frame seperately. Those url's won't show in your location-bar.

The following script does what you currently have in perl or whatever language it is:

Featured Post

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.