• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

How to fix the url?

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
Sohel Rana
Asked:
Sohel Rana
1 Solution
 
mgauravCommented:
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
 
ykf2000Commented:
I think you'll have to use frames in order not to show the real URL
0
 
CJ_SCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now