wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes JavaScript page load get value of anchor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JavaScript page load get value of anchor" Watch "JavaScript page load get value of anchor" New topic
Author

JavaScript page load get value of anchor

Niall Loughnane
Ranch Hand

Joined: Dec 07, 2006
Posts: 208
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 ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61456
    
  67

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 208
Thanks a lot for the replies,

was thinking about using jQuery and will look into it

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JavaScript page load get value of anchor