/    Sign up×
Community /Pin to ProfileBookmark

A simple javascript question

hi guys! I just started learning javascript 5 minutes ago! Now, take a look at this code:

[code=php]
<html>

<head>
<meta name=”GENERATOR” content=”Microsoft FrontPage 5.0″>
<meta name=”ProgId” content=”FrontPage.Editor.Document”>
<meta http-equiv=”Content-Type” content=”text/html; charset=windows-1252″>
<title>New Page 1</title>
<script language=”javascript”>
var message=”hello this is a test of memory”
window.alert(message)
</script>
<script language=”javascript”>
var test=”You should have clicked a link to be able to read this message”
window.alert(test)
</script>

</head>

<body onload=’message’>

<a href=’javascript:window.alert(test);’>klsgdhslhfh<a>
</body>

</html>
[/code]

I wanted to make a message box come up when the body loads, it works, but i wanted to create a link that when clicked, produces another alert.

I already know the code for it, but i want you to show me what is wrong here. I want it to be in the same style (arrays). I want you to tell me also why it comes up when the body loads!

Thanx guys

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@skriptorJan 29.2004 — Hi,

try something like this:
[CODE]<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script type="text/javascript">
var message="hello this is a test of memory"
var test="You should have clicked a link to be able to read this message"

function showMessage(){
window.alert(message);
}
</script>
</head><body onload='showMessage()'>
<a href='javascript:window.alert(test);'>klsgdhslhfh<a>
</body></html>
[/CODE]


There should be no space between java and script.

Good luck, skriptor
Copy linkTweet thisAlerts:
@aommasterauthorJan 29.2004 — thanx alot skriptor. I find it really hard to start learning javascript. Kor has given me a site to read. So i started parctising. Thanx alot
×

Success!

Help @aommaster spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.14,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...