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

Duplicate function name

Hi all,

i have a html page with some javascript functions in a js file linked
to it.
now, if i create a function in the html page with the same name as one
of js functions, how can i call the function that exists on js file
(from html)?

regards,
man shahi

Jul 23 '05 #1
3 9900


ma*******@gmail.com wrote:

i have a html page with some javascript functions in a js file linked
to it.
now, if i create a function in the html page with the same name as one
of js functions, how can i call the function that exists on js file
(from html)?


A second function declaration for the same function name overwrites an
earlier one.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
ma*******@gmail.com wrote:
Hi all,

i have a html page with some javascript functions in a js file linked
to it.
now, if i create a function in the html page with the same name as one
of js functions, how can i call the function that exists on js file
(from html)?


Rename the one in your html page or in your .js file, but you have to
rename one of them.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Jul 23 '05 #3
ma*******@gmail.com wrote:
i have a html page with some javascript functions in a js file linked
to it.
now, if i create a function in the html page with the same name as one
of js functions, how can i call the function that exists on js file
(from html)?


You may copy the whole function:

// this one might be in you linked js file
function foo() {
alert("foo1");
}

// copy the function
var foo_old = foo;

// overwrite the existing function. Do it within another function
// as otherwise the parser might have overwritten foo before
// any execution
function tmp() {
window.foo = function() {
if (foo_old)
foo_old();
alert("foo2");
}
}
// call that function now
tmp();

// call the overwritten function
foo();
If you use objects with prototype, this might be easier:

function o() {
}

o.prototype.foo = function() {
alert("foo1");
};

o.prototype.foo_old = o.prototype.foo;

o.prototype.foo = function() {
if (this.foo_old)
this.foo_old();
alert("foo2");
};

new o().foo();

Daniel
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Gena | last post by:
Hi, Can anyone help me to increment the primary key's value on duplication without using mysql v 4.1 "on duplicate key" function? I can't upgrade to use the "on duplicate key" feature so am now...
1
by: marx | last post by:
I have a bit of a problem and any help would be much appreciated. Problem: I have two dropdown list boxes with same data(all data driven). These are used for two separate entries. For every...
2
by: news | last post by:
I just upgraded to PHP 4.4.2 on my Slackware 10.2 system. And Apache/mySQL/PHP all work great through a browser. No errors. But when I try to run a PHP script through the command line, which I...
5
by: dale.zjc | last post by:
I've got the following table data: 11652 5.99 11652 0.14 12996 5.03 12996 0.12 12996 7.00 And I need to write a query to return only rows 2 and 4, since the remaining rows have duplicate...
0
by: Johan P | last post by:
Having just compiled DBG 2.15.1 and trying to use it with PHP (cli) give some some problem. Verions: DBG 2.15.1 PHP 4.4.4 (cli) It works fine compiled with the Apache module but when I try...
4
by: mcca0081 | last post by:
hi - i'm trying to delete one of the duplicate records based on the most current date. here's the code for my access 2000 db. any help would be appreciated!!! - thank you kindly Sub...
2
by: dayharbor | last post by:
I'm new to VBA and SQL, and help is limited. The following code basically selects duplicate records based on name (last name only, I think). I sort of understand up until the 'WHERE' statement,...
1
by: gelpaks | last post by:
My problem is a bit long and involved, but I will try to summarize. I have created a database using Access 2000 for a cemetery and it now is populated with almost 6,000 names. I created a form so...
0
by: Narendra Gc | last post by:
Hi... I am looking after a lan . I am i am not able to access one particular system , by another one particular system. But from these computers i can access all other systems in my lan and...
7
by: swami | last post by:
What is the query for selecting non duplicate elements for eg: no name age 1 siva 28 2 blair 32 3 mano 28 i want to select blair which hasn't got any duplicate...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.