RF Generation.  The Classic and Modern Gaming Databases.RF Generation.  The Classic and Modern Gaming Databases.

New on the Blogs
Hot Community Blog Entries
Nielsen's Favorites on Channel 4
RF Generation Message Board Welcome, Guest. Please login or register.
Did you miss your activation email?
June 15, 2025, 06:01:22 AM
Home Help Search Calendar Member Map Arcade Login Register
News: RF Generation: Check us out on Discord! Link on the front page!

RF Generation Message Board | Other | Idle Chatter | Java script question 0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] 2 Print
Author Topic: Java script question  (Read 4725 times)
den68
loves White Castle!
DB Contributor
***
Posts: 5746


 Stats
« on: March 23, 2006, 05:36:22 AM »

anyone know how to do multiple redirects?

I've managed to get a single redirect to work using location.replace.

I want to do redirects to different pages depending on what URL you are coming from.

any clues?
Logged

Hydrobond
+5 Insightful
PlayStation
****
United States
Posts: 2728


WWW Stats
« Reply #1 on: March 23, 2006, 06:12:22 AM »

If you know which URL they are coming from, then just use a nested if-else structure.

I think it would go something like this
Code:

if(history.previous() == "http://www.url1.com")
{
       location.replace("http://www.forward1.com")
}
else if(history.previous() == "http://www.url2.com")
{
       location.replace("http://www.forward2.com")
}
else
{
       location.replace("http://www.forward_default.com")
}
« Last Edit: March 23, 2006, 06:12:40 AM by hydrobond » Logged

I never proofread before hitting the submit button, this is why every single one of my posts has been edited in the first minute after being submitted.
den68
loves White Castle!
DB Contributor
***
Posts: 5746


 Stats
« Reply #2 on: March 23, 2006, 08:38:46 AM »

I gave it a shot but it didn't seem to work. it just flipped the 2 url's back and forth without stopping.
Logged

Hydrobond
+5 Insightful
PlayStation
****
United States
Posts: 2728


WWW Stats
« Reply #3 on: March 23, 2006, 08:59:00 AM »

Huh???

Is the forwarding address the page itself?

I'll try that out in a few minutes, when I get the time.
« Last Edit: March 23, 2006, 09:01:44 AM by hydrobond » Logged

I never proofread before hitting the submit button, this is why every single one of my posts has been edited in the first minute after being submitted.
den68
loves White Castle!
DB Contributor
***
Posts: 5746


 Stats
« Reply #4 on: March 23, 2006, 09:26:05 AM »

maybe I just put it in the wrong spot. does it go in the head tag or prior to it?

the url you have as _default is the page itself, correct?
Logged

den68
loves White Castle!
DB Contributor
***
Posts: 5746


 Stats
« Reply #5 on: March 23, 2006, 10:06:23 AM »

here's the link:

http://www.cmgestore.com

can you tell what's wrong?
Logged

St0rmTK421
The Black Perl
Director
*****
Posts: 1248


 Stats
« Reply #6 on: March 23, 2006, 10:40:36 AM »

location.replace, that's a new one.  I've always used

window.location="http://www.yourdomain.com/";

but I assume both work.

Looking at the code you start out with

<script language="JavaScript">
{
if(history.previous() == "http://www.energizerbunnystore.com")
}

Those two extra brackets don't need to be in there.  Just post the code in the same format that hydrobond posted inbetween the <script language="javascript"> and </script> tags.

Also, after playing around, it seems like my browser likes "document.referrer" instead of "history.previous() ".
« Last Edit: March 23, 2006, 10:44:36 AM by St0rmTK421 » Logged

[img width=406 height=60]http://www.rfgeneration.com/yabbattach/lordnep.gif[/img]
We will always keep it on channel 3!
Hydrobond
+5 Insightful
PlayStation
****
United States
Posts: 2728


WWW Stats
« Reply #7 on: March 23, 2006, 10:53:49 AM »

history.previous should have worked, but for some reason I couldn't get it to come back with anything but "undefined."  Referrer worked.
This should work.  
Try it out
Won't let me post the code

w00t, quadruple digit post count!
« Last Edit: March 23, 2006, 11:17:03 AM by hydrobond » Logged

I never proofread before hitting the submit button, this is why every single one of my posts has been edited in the first minute after being submitted.
den68
loves White Castle!
DB Contributor
***
Posts: 5746


 Stats
« Reply #8 on: March 23, 2006, 11:26:58 AM »

okay, now what did I do wrong?

http://www.cmgestore.com/
Logged

Hydrobond
+5 Insightful
PlayStation
****
United States
Posts: 2728


WWW Stats
« Reply #9 on: March 23, 2006, 11:30:55 AM »

You can't have the destination be the same as the source page.  You are forwarding the browser to the page you are currently on, which puts it into that loop.\

Change the URL in the ELSE statement to something like "http://www.cmgestore.com/index2.html"
Logged

I never proofread before hitting the submit button, this is why every single one of my posts has been edited in the first minute after being submitted.
Hydrobond
+5 Insightful
PlayStation
****
United States
Posts: 2728


WWW Stats
« Reply #10 on: March 23, 2006, 11:32:30 AM »

Or better yet, if you want to stay on that page unless they are coming from the energizer page then you can take out the entire else statement.  (Make sure you remove everything in the {} brackets too.)
Logged

I never proofread before hitting the submit button, this is why every single one of my posts has been edited in the first minute after being submitted.
Hydrobond
+5 Insightful
PlayStation
****
United States
Posts: 2728


WWW Stats
« Reply #11 on: March 23, 2006, 11:36:22 AM »

Oh, you only need the javascript on one of the pages, no need to the javascript on the destination page.
Logged

I never proofread before hitting the submit button, this is why every single one of my posts has been edited in the first minute after being submitted.
den68
loves White Castle!
DB Contributor
***
Posts: 5746


 Stats
« Reply #12 on: March 23, 2006, 11:40:52 AM »

okay, that broke the loop but now the links both just got to that main2 page.
Logged

den68
loves White Castle!
DB Contributor
***
Posts: 5746


 Stats
« Reply #13 on: March 23, 2006, 11:47:03 AM »

the energizer and cmgestore urls are both alias's that point to same IP address. could that be the problem?
Logged

Hydrobond
+5 Insightful
PlayStation
****
United States
Posts: 2728


WWW Stats
« Reply #14 on: March 23, 2006, 11:50:56 AM »

Ok, I looked at the code for www.energizerbunnystore.com and from what i can tell you won't need the IF statement there at all if all you want to do is send them directly to www.energizerbunnystore.com/eng2/

Then I would assume you can do away with the script on www.cmgestore.com altogether.

I'm not 100% sure what you are trying to accomplish, can you explain in what you are trying to do with all this?
Logged

I never proofread before hitting the submit button, this is why every single one of my posts has been edited in the first minute after being submitted.
Pages: [1] 2 Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Simple Audio Video Embedder

RF Generation Theme derived from YabbGrey By Nesianstyles | Buttons by A.M.A
Valid XHTML 1.0! Valid CSS!
Page created in 0.11 seconds with 23 queries.
Site content Copyright © rfgeneration.com unless otherwise noted. Oh, and keep it on channel three.