[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to fix the url?

Posted on 2001-07-08
3
Medium Priority
?
199 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…

656 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