/    Sign up×
Community /Pin to ProfileBookmark

help me fix this error in my code

every time i run this script right here

[code]
<script language=”javascript”>

<!– Hide from browsers that do not understand Javascript
//this will welcome people to my site
//when they load my page

function welcome()
{
window.alert(“Welcome to my page”)
var y = window.prompt(“What is your name?”)
window.alert(“Cool i like that name. ” + y + ” just have a certain ring to it.”)
window.alert(“anywho welcome to Heavy metals page”)
}

// end hiding –>

</script>
[/code]

it throws a single error and i dont know how to fix it, the error is

[code]
Error: missing ( before formal parameters
Source File: http://www.bowhuntr.net/heavymetal.htm
Line: 6, Column: 8
Source Code:
function
[/code]

so could someone please tell me what to do to fix it or fix it and poste the fixed version up on here and tell me what was wrong so that i dont make this mistake in the future thanks for helping,
Heavy metal

to post a comment
JavaScript

46 Comments(s)

Copy linkTweet thisAlerts:
@dz_boyJul 15.2005 — You do have the <body onload="JavaScript:welcome()"> tag on the page, right?

Also, you do not need the 'window.' before prompt() or alert().
Copy linkTweet thisAlerts:
@dz_boyJul 15.2005 — Otherwise, it seems to work fine for me. Make sure the script is in the <head> section of the page.
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — yes its in the head and i have "<body onLoad="welcome()>" in my body tag is that wrong ?
Copy linkTweet thisAlerts:
@JPnycJul 15.2005 — "<body onLoad="welcome()>" , yes that's wrong. The function name needs "" around it, you're missing one

<body onLoad="welcome()">
Copy linkTweet thisAlerts:
@UltimaterJul 15.2005 — You do have the <body onload="JavaScript:welcome()"> tag on the page, right?

Also, you do not need the 'window.' before prompt() or alert().[/QUOTE]

and you do not need to put [b]JavaScript:[/b] before welcome() the ony time you really need it is with the HREF attribute so the client knows that the URL is javascript code rather than a hyperlink/URL to go to a totally different page.
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — sorry that was a typo what i have is [b]<body onLoad="welcome()">[/b] so does anyone have any idea why this script wont work for me?
Copy linkTweet thisAlerts:
@CharlesJul 15.2005 — It wopuld seem that something unseen is going wrong. Please post the URL so that we find it.
Copy linkTweet thisAlerts:
@bathurst_guyJul 15.2005 — technically that code should work. but i had a look at your site, you really need to organise yourself a bit more and clean it up.

Whats this:[CODE]<script language="javascript">
function
</script>[/CODE]


Charles, the url is there
Copy linkTweet thisAlerts:
@dz_boyJul 15.2005 — It worked for me:

<html>

<head><title>My Page</title>

<script language="javascript">

<!-- Hide from browsers that do not understand Javascript

//this will welcome people to my site

//when they load my page

function welcome()

{

window.alert("Welcome to my page")

var y = window.prompt("What is your name?", "Name please?")

window.alert("Cool i like that name. " + y + " just have a certain ring to it.")

window.alert("anywho welcome to Heavy metals page")

}

// end hiding -->

</script>

</head>

<body onload="welcome()">

</body>

</html>
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — my site url is "http://www.bowhuntr.net/heavymetal.htm" if you didn't catch it befor and i thought my site was pretty clean and i dont recall having any "<script language="javascript">

function

</script>" on there but ill go look
Copy linkTweet thisAlerts:
@bathurst_guyJul 15.2005 — Clean ... okay ... I have a few housemates so I understand that people have different 'versions' of cleanliness.
Copy linkTweet thisAlerts:
@CharlesJul 15.2005 — Charles, the url is there[/QUOTE]Duh!!

Let see, according to the error message we have a missing "(" on the sixth line. And bathurst_guy has been kind enough to provide that sixth line. It's [font=monospace]function[/font]. And there's no question about it, there's a "(" missing and more.
Copy linkTweet thisAlerts:
@dz_boyJul 15.2005 — Take out that whole <script language="javascript">

function

</script>[/QUOTE]
thing and it will work. Your script was fine, but another part of the pae wasn't letting the browser get that far.
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — well would you please fix it for me?
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — ooooo ok wll still could someone post the correct script please and ty
Copy linkTweet thisAlerts:
@CharlesJul 15.2005 — well would you please fix it for me?[/QUOTE]Please provide the ftp address, your user name and password so that we can delete those three lines from your page.
Copy linkTweet thisAlerts:
@dz_boyJul 15.2005 — Just delete that stupid little <script language="javascript">

function

</script>

Thing from the code on your homepage.
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — or you could just post the correct script for me cause im not handing out any sn's or passes im sorry i just dont trust u all enough not to screw things up
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — ok will do
Copy linkTweet thisAlerts:
@CharlesJul 15.2005 — Just Remove Those Friggin Three Lines.
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — ok i took out the <script language="javascript">

function

</script> but it still says that same error
Copy linkTweet thisAlerts:
@bathurst_guyJul 15.2005 — OMG - you removed it from the wrong spot.....................................
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — o sorry guys i see what your talking about now im so sorry
Copy linkTweet thisAlerts:
@bathurst_guyJul 15.2005 — [CODE]
<html>
<head>
<title>Heavy Metal's page</title>
<style type="text/css">
<!--
.styling{
background-color:black;
color:lime;
font: bold 15px MS Sans Serif;
padding: 3px;
}
-->
</style>
<script language="javascript">
<!-- Hide from browsers that do not understand Javascript
//this will welcome people to my site
//when they load my page
alert("Welcome to my page");
var y = prompt("What is your name?", "Name please?");
alert("Cool i like that name. " + y + " does have a certain ring to it.");
alert("anywho welcome to Heavy metals page");

function Gofindit(){
var searchfor = document.formsearch.findthis.value;

{

var FullSearchUrl =
"http://www.google.com/search?hl=en&lr=&q=" + searchfor ;
location.href = FullSearchUrl;
}}
// end hiding -->
</script>
</head>[/CODE]
Copy linkTweet thisAlerts:
@dz_boyJul 15.2005 — Does it work now?
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — i got it fixed now and its not giving me any more errors but the script still isn't working (god dang i really must suck at this)
Copy linkTweet thisAlerts:
@bathurst_guyJul 15.2005 — I just edited the code above, i put in the ; at the end of each line
Copy linkTweet thisAlerts:
@bathurst_guyJul 15.2005 — oh you need to have a capital L in onLoad
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — ok i have all that but it wont load the function and it wont give me another errror
Copy linkTweet thisAlerts:
@bathurst_guyJul 15.2005 — Ok, ive re-edited the code above. Rather than having it trigger on onLoad just have it run and test it. You can remove onLoad="welcome()" completely from the body tag if you like, this should work
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — hey cool it works but theres just one problem with this whole thing, it still doesn't tell me what i was doing wrong and i needed to know that because im also going to try to make something that can say like "you are now leaving this site" onUnload and i was going to use basicly the same format as the welcome but now since i dont know what i was doing wrong i cant anywho im going to try to look at the html goodies javascript primmers to see if what i was doing wrong so thanks for your help guys
Copy linkTweet thisAlerts:
@CharlesJul 15.2005 — I just edited the code above, i put in the ; at the end of each line[/QUOTE]Those aren't necessary.
Copy linkTweet thisAlerts:
@CharlesJul 15.2005 — oh you need to have a capital L in onLoad[/QUOTE]No you don't. The name of the handler is "onload". HTML is case insensitive so "onLoad" works but JavaScript and XHTML are both case sensitive and you'll need to use "onload" there.
Copy linkTweet thisAlerts:
@bathurst_guyJul 15.2005 — just trying to figure out the problem
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — No you don't. The name of the handler is "onload". HTML is case insensitive so "onLoad" works but JavaScript and XHTML are both case sensitive and you'll need to use "onload" there.[/QUOTE]
charles the html goodies javascript primmers say to use onLoadhttp://www.htmlgoodies.com/primers/jsp/article.php/3478511 go there to see for urself
Copy linkTweet thisAlerts:
@UltimaterJul 15.2005 — charles the html goodies javascript primmers say to use onLoadhttp://www.htmlgoodies.com/primers/jsp/article.php/3478511 go there to see for urself[/QUOTE]
HTML is case insensitive so "onLoad" works as well as "onload" and "ONLOAD". If you changed the DOCTYPE to XHTML, it wouldn't work except for "onload" -- as Charles Stated.
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — HTML is case insensitive so "onLoad" works as well as "onload" and "ONLOAD". If you changed the DOCTYPE to XHTML, it wouldn't work except for "onload" -- as Charles Stated.[/QUOTE]
you have it wrong you all keep saying that html [b]is[/b] case sinsitive but its not i could re-write my html page using all upercase letters or lowercase it wouldn't matter and i dont have a docutype thingy i tryed putting one in there but the code for it was always wrong and it didn't work
Copy linkTweet thisAlerts:
@Jeff_MottJul 15.2005 — you have it wrong you all keep saying that html is case sinsitive[/quote]You sure about that? Let's review.[i]Ultimater[/i]

HTML is case [b]insensitive[/b][/quote]
[i]Charles[/i]

HTML is case [b]insensitive[/b][/quote]
Yep, everyone agrees HTML is case [b]in[/b]sensitive. (Also not to be confused with XHTML, which is case [b]sensitive[/b].)

BTW, it never helps to quote from HTML Goodies. It is well known for having very bad information. Read the [url=http://www.w3.org/TR/html4/]HTML Specification[/url] if you want very good information.

i dont have a docutype thingy i tryed putting one in there but the code for it was always wrong and it didn't work[/quote]You really should learn how to make it work. Your pages will always be invalid HTML until you have a proper doctype. Read through the link I posted above.
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — ok reading


EDIT: also if html goodies had very bad information then where should i have learned html and javascript ?

EDIT(again):Also this mourning when i got up my site was all screwed up because the code on my server somehow misteryously got changed throughout the night and it was all screwed up, i got it fixed now but it was a pain in the but to fix it would any have any idea what happened?
Copy linkTweet thisAlerts:
@CharlesJul 15.2005 — HTML Goodies is about the worst source that there is.

The [url=http://www.w3schools.com/]W3Schools[/url] isn't so bad.

I recommend that you read the following and in order:

http://www.w3.org/MarkUp/Guide/

http://www.w3.org/TR/REC-html32

http://diveintoaccessibility.org/

And then I suggest that you read, mark, learn and inwardly digest the two following documents:

http://www.w3.org/TR/html401

http://www.w3.org/TR/WCAG10/

For JavaScript I like [url=http://search.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=V56VnLpB1V&isbn=0596000480&itm=1][i]JavaScript : The Definitive Guide[/i], by David Flanagan[/url]. But know that:

JavaScript = [url=http://www.ecma-international.org/publications/standards/Ecma-262.htm]ECMAScript[/url] + [url=http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/]DOM[/url]
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — ok ty ill go there
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 15.2005 — ok that first link is messed up cause in there this Dave person says that <p> marks the start of a paragraph and </p> ends it and thats not true <p> simply skips a line befor starting the text again and you need no closing tag thats about as stupid as ppl i'v seen saying that you close a tag like this

example:

<b>test text.....<b/ >

which is just plain stupid unless there is some other form of html that requirs this closing tag

EDIT: and that secound one is for 3.2 i want 4.1
Copy linkTweet thisAlerts:
@CharlesJul 15.2005 — 1) That Dave person wrote the HTML 3.2 Specification and worked on the HTML 4.01 Specification. I can assure you that he knows more about HTML the either of us.

2) Forget what you've been told and especially what you've read from HTML Goodies. HTML isn't about formatting the page, it's about structuring the document. CSS is about formatting the page. The P element indicates a paragraph; it's not a double BR element. You really should use its closing tag if only to keep your head straight but if you omit it the browser inserts one. When you get more fully into JavaScript you will find yourself traversing the document and this will make more sense. But for now, trust Mr. Raggett.

3) No, you want HTML 4.01. If you think that you are man enough to swallow that specification then go right ahead and do so. But I find that the HTML 3.2 specification makes for a nice little introduction to 4.01 - just keep in mind that some of the 3.2 stuff was found to be a bad idea.
Copy linkTweet thisAlerts:
@jackacohenJul 15.2005 — Like HeavyMetal I'm a newbie in js (but perhaps a bit less new), and since no one answered his statement about still not knowing which part of his original attempt was wrong I'll state what may be obvious to more experienced coders (but which I never saw spelled out anywhere, which makes me think it might be worth stating explicitly):

For "debugging", I insert a series of alert lines at obvious points (e.g., one after each function definition) with the message in each telling me where the alert is located (e.g., "now through function getVar()").

With the html file displayed in the browser I "view source," which opens the code in Notepad. Then every time I modify the code I just save it and then refresh the browser, and I immediately see the effect.

Specifically, the last alert I see shows me how far the browser got before it stopped reading my script.

Sometimes I need to turn an entire block of code which follows the last displayed alert into a comment and verify that the alert following that block then displays on load (or, more accurately, when I refresh the browser.) When it does I've got the error "trapped" inside the commented block, which I then un-comment piece-by-piece until the problem is narrowed down to a single line of code.

I hope this isn't so obvious that it was a waste of time to post.
Copy linkTweet thisAlerts:
@CharlesJul 16.2005 — I hope this isn't so obvious that it was a waste of time to post.[/QUOTE]Not at all. I'm reminded of C. S. Lewis' preface to his commentary on the [i]Psalms[/i]. Often it takes a beginner to know just what sort of help another beginner needs.

Another really helpful link - make good friends with [url=http://validator.w3.org/]The Validator[/url].
Copy linkTweet thisAlerts:
@Heavy_MetalauthorJul 16.2005 — well i wouldn't be a newbie if html goodies hadn't had faulty information i mean now i need to go back and forget everything i pounded into my mind for 2 months or so well this is just great another two months of my life wasted can someone just tell me where to find good javascript primmers besides w3schools and all that because i hate them i just dont like there set up so could someone give me somewhere else to go to learn javascript

EDIT:I figured out something about why my functions weren't working, well i found a working example that i'd made befor and in it i put the functions in the body instead of in the head and i tryed it in heavy metal and now they work just find if you go to leave my site it pops up with a deal telling you and the script for it is in the body and it works and i copied and pasted it into the head and it stoped working so i think my problem is solved
×

Success!

Help @Heavy_Metal 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.18,
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,
)...