Computing.Net > Forums > Programming > Javascript math.random() prob

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Javascript math.random() prob

Reply to Message Icon

Name: valdez38
Date: July 28, 2008 at 20:05:55 Pacific
OS: Windows
CPU/Ram: not sure
Product: Dell
Comment:

I cannot get this code to work for me any suggestions?
<script type="text/javascript">
var d = math.random();
if (d <= .04)
{
Window.open(“http://”,width=100%,height=100%);
Window.focus();
}
else if (d > .04 && d <= .08)
{
Window.open(“http://”,width=100%,height=100%);
Window.focus();
}
else if (d > .08 && d <= .12)
{
Window.open(“http://”,width=100%,height=100%);
Window.focus();
}
else
{
Window.open(“http://”,width=100%,height=100%);
Window.focus();
}
</script>



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: July 29, 2008 at 01:39:53 Pacific
Reply:

There are a lot of issues with this code:

- There is no math. There is, however, Math.

- window, not Window.

- and are not real quotes. Use straight quotes.

- window.open() does not deal with percentages.

- Your usage of window.open() shows you never read any documentation about it. I suggest you remedy that.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Javascript math.random() prob

random choice with prob in java www.computing.net/answers/programming/random-choice-with-prob-in-java/12711.html

Javascript help...name generator www.computing.net/answers/programming/javascript-helpname-generator/13989.html

javascript question www.computing.net/answers/programming/javascript-question/17026.html