Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Opening a Page and Immediately going to different URL
Old 08-28-2007, 03:39 PM Opening a Page and Immediately going to different URL
Junior Talker

Posts: 2
Trades: 0
I have page that I am trying to link to another URL (that will set a cookie) and then immediately go to another page. I've tried to get the page to load one URL and then go to the next URL, but I can't get that to work. I honestly don't even know how to begin or how to do it. Any suggestions would be greatly appreciated.
RuthdaWebbie is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-29-2007, 03:47 AM Re: Opening a Page and Immediately going to different URL
Extreme Talker

Posts: 238
Location: United States
Trades: 0
I'm not sure I understand your exact problem, but I can at least tell you how to redirect a page. There are three ways to redirect which are all fairly simple. The first is to send an HTTP Location header. For example, in PHP, this can be done by:
PHP Code:
header('Location: http://www.example.com/'); 
The second way can be done in plain HTML, which is to use a meta refresh.
HTML Code:
<meta http-equiv="refresh" content="0;url=http://www.example.com" />
That example will redirect to example.com in 0 seconds (after the page has either partially or fully loaded). You could make it redirect in 7 seconds by doing the following:
HTML Code:
<meta http-equiv="refresh" content="7;url=http://www.example.com" />
The third way is to use the JavaScript window.location property.
HTML Code:
<script type="text/javascript">
<!--
window.location = "http://www.example.com/"
//-->
</script>
This one might be your best bet if you are trying to set a cookie with JavaScript and then immediately redirect.
__________________
The interlocking pieces of web development: usability, performance, accessibility, and standards.
frost is offline
Reply With Quote
View Public Profile
 
Old 08-29-2007, 01:20 PM Re: Opening a Page and Immediately going to different URL
Junior Talker

Posts: 2
Trades: 0
Let me try to explain this better-it is kind of hard for me to understand. Ok I have this page (page1.html) and I need to set a hyperlink to page2.html (so page2.html will set a cookie) and then move on to page3.html.

My biggest problem is that page2.html is a server-side page that I do not have access to.
RuthdaWebbie is offline
Reply With Quote
View Public Profile
 
Old 08-30-2007, 02:12 AM Re: Opening a Page and Immediately going to different URL
Extreme Talker

Posts: 238
Location: United States
Trades: 0
If you want to redirect to another location from a page which you do not have access to modify, then I am afraid that this most likely cannot be done.

You could try setting a cookie on one of your own pages instead of using page2.html to do it. I don't know if your situation permits that or not.
__________________
The interlocking pieces of web development: usability, performance, accessibility, and standards.
frost is offline
Reply With Quote
View Public Profile
 
Old 08-30-2007, 03:55 AM Re: Opening a Page and Immediately going to different URL
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Yhis "could" be done, but it will not be optimal, and will imply that you have 2 windows opened at a certain time, or you use ajax.

If your page2.html have nothing that the user must read or no actions, you can call it in a ajax request. It will load it in background, and you can setup the return handler to redirect the current windows to page3.html when page2.html finis loading.
The only thing is that if page2.html is not on the same domain, you won't be able to use this method, except by using an ajax proxy, but I don't know about the cookies in that case.

Or, you can have page1.html that open page2.html, and after a predefined timeout, close it and page1.html redirect itself to page3.html.

Either solutions are buggy, and prone to problems, and that raise the real question:
Why do you have to access a page just to setup a cookie, but want to redirect the user from that page directly ?
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to Opening a Page and Immediately going to different URL
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33816 seconds with 12 queries