473,326 Members | 2,813 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,326 software developers and data experts.

Defining and Invoking a Method - how do make it run on a browser?

I studying the example below from a javaScript book, how can I demonstarate and get this to work on a browser? see example.


Expand|Select|Wrap|Line Numbers
  1. function compute_area() {
  2.     return this.width * this.height;
  3. }
  4.  
  5. var page = new Rectangle(8.5,11);  // creates new object
  6.  
  7. page.area = compute_area;         //  defines a method 
  8.  
  9. var a = page.area();              //  invokes new method
  10. alert(a);
Aug 28 '07 #1
1 972
gits
5,390 Expert Mod 4TB
hi ...

simply wrap it with <script> tags and put it in a html-page ... where is the problem? :)

kind regards

ps: and don't forget the code-tags! next time ...
pps: make sure you don't forget the Rectangle-constructor ... that is not contained by your example
Aug 28 '07 #2

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

Similar topics

3
by: bbxrider | last post by:
running win2k adv server/ iis5.0 trying to setup on my web page where browsers can download a file, an .xls so been trying to figure out with a download 'link' what invokes the standard ms file...
0
by: snappa | last post by:
Hello, Does anyone out there know how to invoke a script method on a web page from a custom WebBrowser application? I know I need to hook in at the NavigateComplete event bu can't figure out...
2
by: Jeff | last post by:
I am trying to dynamically load an assembly via reflection and then invoke a method of that assembly that will populate a custom type collection passed into the method byref. I am able to...
16
by: Howard Jess | last post by:
All -- I'm trying to solve a problem for which I think the solution will be to *cheat*; but I don't mind doing so for this case. The background is: Given an object constructor, and an instance...
25
by: MuZZy | last post by:
Hi, I'm currently rewriting some functionality which was using multithredaing for retrieving datasets from database and updating a grid control. I found that the grids (Infragistics UltraGrid,...
1
by: Suds | last post by:
Hi, I'm having an issue with invoking a Generic method that takes Generic Arguments. My method signature is public void GenericMethodWithGenericArguments<E, V>(List<EtheFirstList,...
3
by: Rotsey | last post by:
Hi, I am getting a Exception has been thrown by the target of an invocation error when invoking a method Here is the crux of the code. I realise it could be a few things, any one give me...
2
by: =?Utf-8?B?SmltIE93ZW4=?= | last post by:
Hi John, Hopefully this post will find its way back to you - or perhaps be answered by someone else. As I mentioned in my last post on the earlier portion of this thread, changing the...
0
by: everlast88az | last post by:
I have created an active x web browser axWebBrowser1. I navigate to the url through: axWebBrowser1.Navigate(URL, ref Zero, ref EmptyString, ref EmptyString, ref EmptyString); ...
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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.