This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2011-09-02 14:30:46

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

HTML Redirecting!

How do I redirect a user to another website/page automatically? I tried it once and it didn't work.


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#2 2011-09-02 14:44:04

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: HTML Redirecting!

using javascript

Code:

<script>
window.top.location.href= 'http://www.whatever.com';
</script>

and please consider reading w3schools once  wink  or searching it over stackoverflow


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#3 2011-09-02 15:07:01

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: HTML Redirecting!

fanofcena is right  smile
w3schools is a great place to start learning HTML, CSS, JS, PHP and whatever else you may need for programming on the web  smile

Also if you have PHP access on your server, the javascript method is ew  tongue

Code:

<?php
header('Location: http://scratch.mit.edu');
?>

http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#4 2011-09-02 15:25:13

sparks
Community Moderator
Registered: 2008-11-05
Posts: 1000+

Re: HTML Redirecting!

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  smile


http://img541.imageshack.us/img541/7563/scratchbetabanner.png

Offline

 

#5 2011-09-02 15:28:19

WindowsExplorer
Scratcher
Registered: 2011-02-25
Posts: 1000+

Re: HTML Redirecting!

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  smile

kk!  smile


http://i.imgur.com/H6LLdnK.pnghttp://i.imgur.com/VYuD7BY.png

Offline

 

#6 2011-09-03 11:39:23

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: HTML Redirecting!

JSO wrote:

fanofcena is right  smile
w3schools is a great place to start learning HTML, CSS, JS, PHP and whatever else you may need for programming on the web  smile

Also if you have PHP access on your server, the javascript method is ew  tongue

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  tongue  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)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#7 2011-09-03 12:07:05

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: HTML Redirecting!

@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  tongue  Also because it's way faster, you don't even notice a browser following a location header.


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#8 2011-09-03 12:24:21

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: HTML Redirecting!

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 headers  tongue  Also 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"


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

#9 2011-09-03 15:21:57

JSO
Community Moderator
Registered: 2007-06-23
Posts: 1000+

Re: HTML Redirecting!

Uncaughtexception? That's neat. but you never know what widll happen after the exception ofcourse...


http://oi48.tinypic.com/2v1q0e9.jpg

Offline

 

#10 2011-09-03 16:20:16

fanofcena
Scratcher
Registered: 2008-07-03
Posts: 1000+

Re: HTML Redirecting!

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  wink

oh hey btw think of my offer on your project as a message !

Last edited by fanofcena (2011-09-03 16:21:39)


http://i53.tinypic.com/2vxr2c0.png Click whats above u might make a cute planet happy ^_^

Offline

 

Board footer