Jump to content

Create link


Fire Dragon

Recommended Posts

Hi!I need help with questionbox.Here is my code:

<script type="text/javascript">function question(){var answer=prompt('What you are doing?',' ');var right='Writing';if (answer==right){URL HERE}}</script>´

Okay,how I can se so,that when user answers right,he transfers to new url.How I can set there,where now reads URL HERE,code what transfers you to new html page?Thank you very much!

Link to comment
Share on other sites

like this

<html><head><script type="text/javascript">function question(){var answer=prompt("What are you doing ?","")if (answer == "right"){window.location="http://www.w3schools.com"}}</script></head><body><form><input type="button" onclick="question()" value="Display a prompt box"></form></body></html>

this code need an button

<html><head><script type="text/javascript">var answer=prompt("What are you doing ?","")if (answer == "right"){window.location="http://www.w3schools.com"}</script></head>

this code no need a button:)

Link to comment
Share on other sites

I met new trouble.I set time limit to my html document,where that prompt box is.It redirectes you to another webpage,if you can't answer in right time.However,here is my proble:If you write to prompt box,and code redirectes you same time to another page,box remains on screen,and you can write your answer there.And if you answer is right,it's brings you to page,where you come if you answer right.Well.I want thatif time is up,and browser redirectes you to new site,you can't answer anymore.Is there code,what destroys that prompt box,or anything else way,how I can prevent anwering after URL is changed?Here is my redirection code:

<meta http-equiv="Refresh"content="10;url=http://www.w3schools.com">

Link to comment
Share on other sites

your code like this ?

<html><head><meta http-equiv="Refresh"content="10;url=http://www.w3schools.com"><script type="text/javascript">function question(){var answer=prompt("What are you doing ?","")if (answer == "right"){window.location="http://www.w3schools.com"}}</script></head><body><form><input type="button" onclick="question()" value="Display a prompt box"></form></body></html>

I don't understand why you have to do this , you want promt box to take you to one page , while your browser automatically leads you to that page too for 10 seconds , it 's not necessary :)

If you write to prompt box,and code redirectes you same time to another page,box remains on screen,and you can write your answer there.And if you answer is right,it's brings you to page,where you come if you answer right.Well.I want thatif time is up,and browser redirectes you to new site,you can't answer anymore.
I see that difference with youwhen I have no click on button , the page will direct to url after 10 secondswhen I click on the button , and don't type in it , the page hasn't change to the new url after 10 seconds , it waits till you click OK to make the prompt box lost when I click on button , and wait till 10 seconds pass by , whatever I fill in textarea , the page still direct to the url :)
Link to comment
Share on other sites

Yes...My code is just like that,but unlike you,it redirects you to new page,when prompt bo is open.Hmm,what browser you use?I use Fire Fox,so it might have something with this.Well,I tested it with Opera,and it works like you said,so Fire Fox is the problem.Thanks anyway! :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...