Author
JavaScript page load get value of anchor
Niall Loughnane
Ranch Hand
Joined: Dec 07, 2006
Posts: 159
posted Jan 12, 2012 09:15:13
0
Hi,
I have the following HTML and JavaScript code:
what i am trying to do is to alert the value of the field "anchor" when the page loads,
currently it only alerts when the field is clicked,
is it possible to alert when the page loads?
Thanks in Advance,
Niall
Jee Ba
Greenhorn
Joined: Feb 08, 2011
Posts: 7
Yes it is possible,
But if you want something more CrossBrowser, maybe you should check the jquery library ready event
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
Jee Ba wrote: Yes it is possible,
Bad practice! Behavior shouldn't be mixed in with the document markup.
The original tactic of using:was on the right track, but should be:
Note, no parens!
But I do agree that using jQuery for event handling is great idea.
[Smart Questions ] [JSP FAQ ] [Books by Bear ] [Bear's FrontMan ] [About Bear ]
Jee Ba
Greenhorn
Joined: Feb 08, 2011
Posts: 7
I agree with Mr Bear, its a bad practice to put javascript on your HTML. Using external js files, will make your code more easy to read , also know as "beautiful code". Hope this complement your original question.
Niall Loughnane
Ranch Hand
Joined: Dec 07, 2006
Posts: 159
posted Jan 12, 2012 10:52:04
0
Thanks a lot for the replies,
was thinking about using jQuery and will look into it
Thanks
subject: JavaScript page load get value of anchor