Question:

Whats rong with my javascript code

by  |  earlier

0 LIKES UnLike

<head>

<script language="JavaScript">

<!--hide

var spaceq;

var spacename="randomdiscussion";

spaceq=prompt("What space is this?"," ");

if (spaceq==spacename)

alert("Off to Space-R, then!")

window.location="http://www.space-r.wi...

else

{

window.location="http://www.wikispaces.c...

}

//-->

</script>

</head>

HELP

 Tags:

   Report

3 ANSWERS


  1. You need a curly brace ({) after the IF statement and one (}) before the ELSE clause.

    As it is, only the alert will fire but you won&#039;t be redirected anywhere.

    I suspect you are also receiving some sort of syntax error with this code.


  2. you have a lethal virus you should call the computer company to indentify it

  3. Here, I have edited bits with your code, try it and if it still don&#039;t work tell me:

    &lt;head&gt;

    &lt;script language=&quot;JavaScript&quot;&gt;

    var spaceq;

    var spacename=&quot;randomdiscussion&quot;;

    spaceq=prompt(&quot;What space is this?&quot;,&quot; &quot;);

    if (spaceq==spacename)

    {

    alert(&quot;Off to Space-R, then!&quot;)

    window.location=&quot;http://www.space-r.wi...

    }

    else

    {

    window.location=&quot;http://www.wikispaces...

    }

    &lt;/script&gt;

    &lt;/head&gt;

    try that

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.