Multiple script blocks?

J

joe

I need to call javascript code from within body block. The below code runs fine
will I run into problem with some browsers or is there a better way?

<html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<SCRIPT LANGUAGE="JavaScript">
function test1() {
document.write("Hi there");
return true; }
</SCRIPT>

</head>

<body>

<SCRIPT LANGUAGE="JavaScript">
document.write("Hello world and ");
test1();
</SCRIPT>

</body>
</html>
 
R

Randy Webb

joe said the following on 4/27/2006 9:48 AM:
I need to call javascript code from within body block. The below code runs fine
will I run into problem with some browsers or is there a better way?

Yes, there is a better way.
<html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<SCRIPT LANGUAGE="JavaScript">
function test1() {
document.write("Hi there");
return true; }
</SCRIPT>

</head>

<body>

<SCRIPT LANGUAGE="JavaScript">
document.write("Hello world and ");
test1();

document.write("Hi there");

Why use a function for a one time use? Or, are you re-using the
function? Also, if you run the function after the page loads you will
run into more problems.

Read the Group FAQ.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top