Jump to content


javascript


5 replies to this topic

#1 Warbz

    IRC is just a multiplayer notepad.

  • Project Team
  • 4646 posts

Posted 26 November 2007 - 15:22

a little help please.
Im using to followong code....

<html>
<head>
<script type=&#34;text/javascript&#34;>
function disp_prompt&#40;&#41;
  {
  var name=prompt&#40;&#34;Please enter your name&#34;,&#34;Your name&#34;&#41;
  if &#40;name!=null && name!=&#34;&#34;&#41;
	{
	document.write&#40;&#34;Hello &#34; + name + &#34;Thankyou for visiting. please continue to <a href=&#34;http&#58;//warbz18.aexwow.com&#34;> Warbz&#39;s Webpage</a>&#34;&#41;
	}
  }
</script>
</head>
<body>

<input type=&#34;button&#34; onclick=&#34;disp_prompt&#40;&#41;&#34; value=&#34;Click me to continue.&#34; />

</body>
</html>





basically i want the user to click the "click me to coninue" box then a pop up asking for there name appears, then it will say welcome, etc.
then when they click on the dialogue box with the greetin, it will forward them to the appropriat epage of the website.
I have a feeling part of the prob is that im using a html script within the javascript. but i dunno how to make links in javascript.

any help is greatly appreciated.

Edited by Warbz, 26 November 2007 - 15:23.


Posted Image

#2 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 26 November 2007 - 16:37

You're missing the ; at the end of the statements:

var name=prompt&#40;&#34;Please enter your name&#34;,&#34;Your name&#34;&#41;;

document.write&#40;&#34;Hello &#34; + name + &#34;Thankyou for visiting. please continue to <a href=&#34;http&#58;//warbz18.aexwow.com&#34;> Warbz&#39;s Webpage</a>&#34;&#41;;


To link to another page in JS, use:
location = &#34;whereveryouwanttogo&#34;;

CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb

#3 Liliana

    natural power

  • Member
  • 645 posts

Posted 26 November 2007 - 18:01

View PostWarbz, on 26 Nov 2007, 16:22, said:

{
document.write("Hello " + name + "Thankyou for visiting. please continue to <a href="http://warbz18.aexwow.com"> Warbz's Webpage</a>")
}

You need to escape the quotation marks and the slashes in the text. It's supposed to look like this:
{
document.write&#40;&#34;Hello &#34; + name + &#34;Thankyou for visiting. please continue to <a href=\&#34;http&#58;//warbz18.aexwow.com\&#34;> Warbz&#39;s Webpage</a>&#34;&#41;;
}

Edited by Prince Kassad, 26 November 2007 - 18:02.

Quote

Anyway,the China's army is a modernize army,this army can bear down all country's army.
I hope SWR team can modification the China in the RISE OF THE RED and SHOCKWAVE mods.China is a modernize country.Maybe in thirty years later,the China will be a big and powerful country,overrun the US

Quote

[22:23:32] <J8a> why would i read a eula anyway?
[22:23:41] <J8a> they're not written in english
[22:23:59] <J8a> THEY ARE WRITTEN IN, BUT NOT LIMITED TO, CAPITAL LETTERS.

#4 Warbz

    IRC is just a multiplayer notepad.

  • Project Team
  • 4646 posts

Posted 26 November 2007 - 21:38

k thx
#EDIT:

still dont work =/

<html>
<head>
<script type=&#34;text/javascript&#34;>
function disp_prompt&#40;&#41;
  {
  var name=prompt&#40;&#34;Please enter your name&#34;,&#34;Your name&#34;&#41;;
  if &#40;name!=null && name!=&#34;&#34;&#41;
	{
	document.write&#40;&#34;Hello &#34; + name + &#34;Thankyou for visiting. please continue to <a href=&#34;http&#58;//warbz18.aexwow.com&#34;> Warbz&#39;s Webpage</a>&#34;&#41;;
	}
  }
</script>
</head>
<body>

<input type=&#34;button&#34; onclick=&#34;disp_prompt&#40;&#41;&#34; value=&#34;Click me to continue.&#34; />

</body>
</html>


is that right?

Edited by Warbz, 26 November 2007 - 21:42.


Posted Image

#5 CodeCat

    It's a trap!

  • Gold Member
  • 6111 posts

Posted 26 November 2007 - 22:13

Read Kassad's post.
CodeCat

Posted Image
Posted Image

Go dtiomsaítear do chód gan earráidí, is go gcríochnaítear do chláir go réidh. -Old Irish proverb

#6 Warbz

    IRC is just a multiplayer notepad.

  • Project Team
  • 4646 posts

Posted 26 November 2007 - 22:20

*hits self on head*
sorry and thanks

Posted Image



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users