?
Solved

How to fix the url?

Posted on 2001-07-08
3
Medium Priority
?
194 Views
Last Modified: 2008-03-17
Hello:

I have one redirect cgi script which redirect to the another url immediately. And the url shows in the address in the explorer, it doesnt change. Here is the Script:

---------------------------------------------------
#!/usr/bin/perl

$domain = $ENV{'HTTP_HOST'};

#################################################################
# Look for domain name and convert to real location
# PLEASE CHANGE domain names and locations to your own

if (($domain eq 'www.domain1.com') || ($domain eq 'domain1.com')) {
  &Redirect("http://www.domain2.com/index.html",
          "Asian Classified.COM",
          "Best Classifieds Service",
          "classifieds,asia,asian,ad,business,free,travel",
          "Author",
          "Domain2.com",
          "Copyright (c) 1999-2001 Domain2.com"  )
}



 
#################################################################
# Redirect to real location. Real URL will hidden
# Function parameters:
#   0. Real URL location  - required
#   1. Site Title         - required
#   2. Site Description
#   3. Site Keywords
#   4. Site Author
#   5. Site Owner
#   6. Site Copyright

sub Redirect { #
 print "Content-type: text/html\n\n";

 print "<html><head>\n";
 print "<meta name=\"Description\" content=\"$_[2]\">\n";
 print "<meta name=\"KeyWords\" content=\"$_[3]\">\n";
 print "<meta name=\"Author\" content=\"$_[4]\">\n";
 print "<meta name=\"Owner\" content=\"$_[5]\">\n";
 print "<meta name=\"Object\" content=\"Free\">\n";
 print "<meta name=\"Robots\" content=\"ALL\">\n";
 print "<meta name=\"Copyright\" content=\"$_[6]\">\n";
 print "<title>$_[1]</title>\n";
 print "</head>\n";

 print "<frameset frameborder=0 framespacing=0 border=0 rows=\"100%,*\" noresize>\n";
 print "<frame name=\"frame\" src=\"$_[0]\" noresize>\n";
 print "</frameset>\n";
 print "<meta http-equiv=refresh content=\"0; url=$_[0]\">\n";
 print "<a href=\"$_[0]\">$_[0]</a></html>\n";
 exit;
}

------------------------------------------------------

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?

Thanks

Rana
0
Comment
Question by:Sohel Rana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 2

Expert Comment

by:mgaurav
ID: 6262205
You can make frames using JavaScript only if you create the whole page with JS, like with window.open(...) fn.
 Try this:

newWin = window.open("","","<params>");
newWin.document.writeln("<html>...");
newWin.document.writeln("<frameset...");
...
..
.

Hope it helps.
0
 
LVL 4

Expert Comment

by:ykf2000
ID: 6262285
I think you'll have to use frames in order not to show the real URL
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 400 total points
ID: 6262308
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:

The following is your frameset page (index.html)

<html>
 <head>
  <script>
    var QueryString = new Array();
    mArr = location.search.substring(1).split("&");
    for(i=0;i<mArr.length;i++)
    {
       t = mArr[i].split("=");
       QueryString[t[0]] = unescape(t[1]);
    }

    mainPage = (QueryString["url"] && QueryString["url"]!="")?QueryString["url"]:"normalpage.htm";
  </script>
 </head>

 <script>
   sStr = "<frameset frameborder=0 framespacing=0 border=0 rows='*,0' noresize>\n"
   sStr += "<frame name='frame' src='" + mainPage + " noresize>\n";
   sStr += "</frameset>\n";
   document.write(sStr);
 </script>
</html>

and in each content-page you place:
<script>
if(top.location==location)
{
   location.replace("index.htm?url="+escape(location));
}
</script>

Regards,
CJ
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question