473,322 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Would this be bad scripting?

Death Slaught
1,137 1GB
Would it be considered bad scripting if you wrote a script in javascript but used html for just regular text? or does it matter? heres an example.

[HTML]<html>
<script type="text/javascript">
var name1;
name1=prompt("Hi what's your name?")

if (name1 == "name")
{
alert("Hello name")
}
else
{
alert("Hello" + " " + name1 +"!")
}
document.write("Welcome!")
</script>
</html>[/HTML]

Instead of that do this.

[HTML]<html>
<script type="text/javascript">
var name1;
name1=prompt("Hi what's your name?")

if (name1 == "name")
{
alert("Hello name")
}
else
{
alert("Hello" + " " + name1 +"!")
}
</script>
<body>
Welcome!
</body>
</html>[/HTML]


Thanks, Death Slaught
Aug 14 '07 #1
4 1046
epots9
1,351 Expert 1GB
Would it be considered bad scripting if you wrote a script in javascript but used html for just regular text? or does it matter?
<snip>
I wouldn't think so, but i guess it depends on what u need done.

jusst to point something out, javascript should only be declared between the head tag and/or the body tag.
Aug 14 '07 #2
Death Slaught
1,137 1GB
I wouldn't think so, but i guess it depends on what u need done.

jusst to point something out, javascript should only be declared between the head tag and/or the body tag.
ok thanks ill try to remember to put it in the head or body tags next time lol
Aug 14 '07 #3
pbmods
5,821 Expert 4TB
Heya, Death.

As a general rule, it is faster for the browser to render straight-up HTML then to use document.write().

You would more appropriately want to use JavaScript if you needed to add text to a page after it was done loading, for example.
Aug 14 '07 #4
acoder
16,027 Expert Mod 8TB
As pointed out, you're better off using HTML for simple text output. However, if you need to depend on some user input, for example, for the output, then it'd make sense to use document.write. Take your example. Instead of the alert, you could have used a document.write:
Expand|Select|Wrap|Line Numbers
  1. document.write("Welcome " + name1 + "!");
If at all possible you should avoid using Javascript where simple HTML should suffice.
Aug 15 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

41
by: Richard James | last post by:
Are we looking at the scripting world through Python colored glasses? Has Python development been sleeping while the world of scripting languages has passed us Pythonista's by? On Saturday...
24
by: Charif Lakchiri | last post by:
Okay, here's what I know so far about Python: It's an object-oriented scripting language, supported on many platforms. Now here are my questions: It is easy to learn? Does it support GUI...
33
by: Quest Master | last post by:
I am interested in developing an application where the user has an ample amount of power to customize the application to their needs, and I feel this would best be accomplished if a scripting...
8
by: Rodd Snook | last post by:
I have an application which makes extensive use of the Scripting.Dictionary object. I'm not doing anything silly like putting them outside the page scope -- just creating quite a few of them and...
2
by: Tim Chmielewski | last post by:
I have been trying to read values from a form into an array on a page without much success and was told to use a Scripting.Dictionary instead. There are a variable number of fields on the form as...
0
by: fiona | last post by:
Catalyst Releases Scripting Editions of SocketTools Client and server-side development for Active Server Pages and PHP. Yucca Valley, CA, May 25, 2005 - Catalyst Development Corp...
8
by: rmacias | last post by:
I am maintaining an application that was writting in VB6 and has VBA 6.2 integrated into it. The VBA SDK allows the users of the application to generate VBA projects and scripts to gain access to...
6
by: Wolfgang Keller | last post by:
Hello, I'm looking for a spreadsheet application (MacOS X prefered, but Windows, Linux ar available as well) with support for Python scripting (third-party "plug-ins" are ok) and a database...
1
by: andrewcw | last post by:
I have used System.Management in the past to extract and walk thru drives & check their type. I can also do it with COM's FileSystemObject. Here I am trying to just use the Management Object...
111
by: Enteng | last post by:
Hi I'm thinking about learning C as my first programming language. Would you recommend it? Also how do you suggest that I learn it?What books/tutorials should I read for someone like me? Thanks...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.