Solved

How to fix the url?

Posted on 2001-07-08
3
185 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
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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…

929 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now