473,399 Members | 4,177 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,399 software developers and data experts.

Why does function statement and anything contained within get ignored by browsers?

If I insert the following into my webpage the javascript code works fine:

Expand|Select|Wrap|Line Numbers
  1.   <script type="text/javascript">
  2.  
  3.     alert("message");
  4.  
  5.   </script>
  6.  
But if I insert this code, nothing happens:
Expand|Select|Wrap|Line Numbers
  1.   <script type="text/javascript">
  2.  
  3.      function greetUser()
  4.      {
  5.         alert("message");
  6.      }
  7.  
  8.   </script>
  9.  
Nov 21 '10 #1

✓ answered by Dormilich

why should something happen? you have defined a function (greetUser()), nothing more, nothing less. if you want the alert to pop up, you need to call the function:
Expand|Select|Wrap|Line Numbers
  1. greetUser();

2 1110
Dormilich
8,658 Expert Mod 8TB
why should something happen? you have defined a function (greetUser()), nothing more, nothing less. if you want the alert to pop up, you need to call the function:
Expand|Select|Wrap|Line Numbers
  1. greetUser();
Nov 22 '10 #2
Well that was stupid of me. Thank you for replying to such a stupid mistake just the same :)
Nov 22 '10 #3

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

Similar topics

4
by: Maxd out | last post by:
Hi all As a newbie to C++ just wondering if you can compare a user input e.g. the integer 2 to see if that integer is contained within a parameter list. If so how can it be done and can it be...
1
by: Red Ogden | last post by:
The following script returns an error saying document.all is null or not an object when I try to call the write_layer function more than once within the same else statement i.e.: else {...
2
by: John | last post by:
Hi all, How do I iterate through a specific placeholder and remove or hide all controls contained within that placeholder? Regards John.
0
by: Mike Wilmot | last post by:
In converting a page from ASP to ASPX, I am getting the error: BC30289: Statement cannot appear within a method body. End of method assumed. when running the code below. It has something to do...
0
by: Carlos Oliveira | last post by:
For ASP.NET beginners (like me): I'm trying to migrate "easily" my ASP pages to ASPX pages. Of course, I found the error below: BC30289: Statement cannot appear within a method body. End of...
6
by: ljlevend | last post by:
In my app the user can draw an arbitrary path onto an image. Now I need to determine all of the pixels that are contained within that path. Note that the path can intersect itself and I can...
0
by: Serdge Kooleman | last post by:
C# 2005 how to remove warning "The file 'C:\Main.cs' does not support code parsing or generation because it is not contained within a project that supports code. i created the web project...
2
by: p_cranfield | last post by:
Hi I am trying to work out how to move controls contained within a user controls at design time using the mouse in the IDE. Consider the following: Project A contains usercontrol1 with...
1
by: mark4asp | last post by:
<form runat="server"automatically adds <divtag to code contained within. Is there a way to stop that? Mixing block-level elements with inline-level elements messes up the HTML becasuse that is...
0
by: Peter Morris | last post by:
When I compile a WinForm app I get the following warning: The file 'C:\Data\CustomerProjects\Inteevo\Projects\AlterEgo\AlterEgo\WizardStepControls\SceneSettingsStepControl.cs' does not support...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.