How do I redirect a user to another website/page automatically? I tried it once and it didn't work.
Offline
using javascript
<script> window.top.location.href= 'http://www.whatever.com'; </script>
and please consider reading w3schools once
or searching it over stackoverflow
Offline
fanofcena is right
w3schools is a great place to start learning HTML, CSS, JS, PHP and whatever else you may need for programming on the web
Also if you have PHP access on your server, the javascript method is ew
<?php
header('Location: http://scratch.mit.edu');
?>Offline
WindowsExplorer it's great that you're learning HTML but this isn't really the place to ask questions about it, It's still a place to ask where you get answers though and since most people won't mind (including me) go ahead, but please keep it to one topic
Offline
sparks wrote:
WindowsExplorer it's great that you're learning HTML but this isn't really the place to ask questions about it, It's still a place to ask where you get answers though and since most people won't mind (including me) go ahead, but please keep it to one topic
![]()
kk!
Offline
JSO wrote:
fanofcena is right
![]()
w3schools is a great place to start learning HTML, CSS, JS, PHP and whatever else you may need for programming on the web![]()
Also if you have PHP access on your server, the javascript method is ew![]()
Code:
<?php header('Location: http://scratch.mit.edu'); ?>
@JSO no offence but php === ewer then javascript
as going server side
a simple 1 line node.js / spidermonkey SSJS server code would eradicate all the redirecting needs
in a far more efficient way then firing an apache thread (though less lived but you rock when u dont block)
Last edited by fanofcena (2011-09-03 11:46:53)
Offline
@fanofcena
I've been doing a lot of node + Socket.IO lately and it is indeed an epic piece of servering.
But the web just works in requests, the good old apache+php model that just calls a thread for one request works perfectly.
An error in php code causes 1 php thread to crash (one request). An error in a node script just takes down the whole server for everyone.µ
The reason PHP is better in this case, is because the JS redirection is happening client side here. Those things should just be done by headers
Also because it's way faster, you don't even notice a browser following a location header.
Offline
JSO wrote:
@fanofcena
I've been doing a lot of node + Socket.IO lately and it is indeed an epic piece of servering.
But the web just works in requests, the good old apache+php model that just calls a thread for one request works perfectly.
An error in php code causes 1 php thread to crash (one request). An error in a node script just takes down the whole server for everyone.µ
The reason PHP is better in this case, is because the JS redirection is happening client side here. Those things should just be done by headersAlso because it's way faster, you don't even notice a browser following a location header.
agreed but well i dont like Apache php anymore in beginning it was awesome but since writing realtime apps i am amazed by node.js its much much more effecient then apache and php .. and btw
using on('uncaughtexception', ) ; you might save that "Crash for all"
Offline
JSO wrote:
Uncaughtexception? That's neat. but you never know what widll happen after the exception ofcourse...
i said Might (hehe)
on all my projects uncaughtexception floods thee data to a flatfile..
and monit then restarts the node which loadss data from the flatfile and attains the state just before crash
oh hey btw think of my offer on your project as a message !
Last edited by fanofcena (2011-09-03 16:21:39)
Offline