Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

url changing script

Status
Not open for further replies.

apexinternet

Programmer
May 28, 2001
30
0
0
US
Greetings!

How would you write a script that would change open up a popup window, placing the popup window behind the current window and display a different url each time the page was opened from a list.

ex:


like

I open once it shows
someone else opens it it shows
a third person opens it it shows
fifth, tek-tips.com

and 6th would show again

and continue to rotate like that?

Currently I have it written in asp and javascript. The javascript for the popup window, and asp for the database or urls and such. However, I need this page to completely be an html document, hence the need to code this in javascript. In help would be greatly appreciated.

Christopher Norris
Director, IS/IT Development/Application Engineering
Evision Marketing Group L.L.C.
 
so you want them to rotate, and not just a completely random link. right? The pen is mightier than the sword.
 
yes...rotate..

one at a time..so some how it needs to keep a report of what banner(url) is currently showing.

Let me know,

Chris
 
The only way possible for your requirements is to have a server-side script.
 
How would I write a server-side script to do this.. I am not very familiar with server side scripting.

Chris
 
The only server-side language I know at all is PERL. And in PERL I'm not very fluent (I need to look at a dictionary for just about every word I say). But here's a PERL script I came up with that should do the job you described:
Code:
#!C:/perl/bin/perl

open (HANDLER, "redirect.html");
my @rray = <HANDLER>;
close(HANDLER);
print &quot;Location: &quot;;

my $num = ${rray[0]+1};
$num = $num + 1;
while (&quot;${rray[$num]}&quot; eq &quot;\n&quot;) {
 $rray[$num] = &quot;&quot;;
 $num = $num + 1;
 if ($num > $#rray) {
  $num = 1;
 }
}
if ($num > $#rray) {
 $num = 1;
}
print &quot;${rray[$num]}&quot;;
$rray[0]=$num - 1;
$rray[0]=&quot;${rray[0]}\n&quot;;
print &quot;\n\n&quot;;
open (HANDLER, &quot;>redirect.html&quot;);
for (my $i = 0; $i < $#rray + 1; $i++) {
 print HANDLER &quot;${rray[$i]}&quot;;
}
close(HANDLER);
The first line of the code defines where the PERL interpreter is. Ask your site's administrator for that info. There is a required file also to be in your executable directory: redirect.html. Its contents should look something like this:
Code:
0
../htmaker.html
helloworld.html
../index.shtml
[URL unfurl="true"]http://www.google.com[/URL]

The first line of redirect.html must be an integer. It defines which page will be displayed next. Then the rest of the lines can define whatever you want your random pages to be.
 
Hey Man,

Where does this store the current banner permanently...it has to be there permanently until someone accesses it..then it changes it again...maybe in a data file?

God Bless
Chris


Habakkuk 1:5
 
Code:
#!C:/perl/bin/perl

open (HANDLER, &quot;redirect.html&quot;);
my @rray = <HANDLER>;
close(HANDLER);
print &quot;Location: &quot;;

my $num = ${rray[0]+1};
$num = $num + 1;
while (&quot;${rray[$num]}&quot; eq &quot;\n&quot;) {
 $rray[$num] = &quot;&quot;;
 $num = $num + 1;
 if ($num > $#rray) {
  $num = 1;
 }
}
if ($num > $#rray) {
 $num = 1;
}
print &quot;${rray[$num]}&quot;;
$rray[0]=$num - 1;
$rray[0]=&quot;${rray[0]}\n&quot;;
print &quot;\n\n&quot;;
open (HANDLER, &quot;>redirect.html&quot;);
for (my $i = 0; $i < $#rray + 1; $i++) {
 print HANDLER &quot;${rray[$i]}&quot;;
}
close(HANDLER);



The above code should be put into a .cgi or .pl file inside your server's executable directory (on most servers, it's the folder
Code:
cgi-bin
). Set the first line to point to wherever your PERL interpreter is.

The storage for which page will be accessed next is within
Code:
redirect.html
, which is stored in the same folder as the PERL script. Its first line gives the number of the next page that will appear. All the rest of the lines are simply URL's.
 
just do it like this :

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>
<!--
function myLoader() {
var myArray = new Array(' var myRandom = Math.round(Math.random()*myArray.length);
for(var x = 0; x<myArray.length; x++) {
if (myRandom == x) {
window.open(myArray[x]);
}
}
}
document.onload = myLoader();
//-->
</script> Regards

Big Bad Dave

davidbyng@hotmail.com
 
BigBadDave: Read
Quote:

yes...rotate..

one at a time..so some how it needs to keep a report of what banner(url) is currently showing.

Let me know,

Chris
 
PS: Using JavaScript will mean that eventually, someone's going to find out that it's the JavaScript that makes it tick. Then, they will turn off JavaScript and add to the list of people who have it disabled.
 
yes but this was posted in the JAVASCRIPT Forum or can't you read??? Regards

Big Bad Dave

davidbyng@hotmail.com
 
Yes, well... In some cases, CGI is better than JavaScript. Keep in mind that we're making posts for the betterment of mankind ;-)
 
yes, Big Bad Dave, but it wont store the current url anywhere in javascript..whereas in perl it was. Can you solve this? It needs to keep up which banner is currently showing. so it can rotate.

Thanks
Chris

God is GOOD!
 
apexinternet:

Why exactly do you want it to rotate in an orderly fashion, rather than randomly selecting, anyway? ---------------------------------------------
They that give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.
 
Because we are going to charge for a banner..we want it to rotate one at a time..in an orderly fashion..perhaps the javascript(if you can do this) would write a data file (txt) file out on the server, and use it?

Any help would be greatly appreciated.

Chris


GOD IS FAITHFUL!
 
You can't use client-side JavaScript to write server side files!!! Regards

Big Bad Dave

davidbyng@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top