Click here to Skip to main content
12,885,784 members (38,334 online)
Rate this:
Please Sign up or sign in to vote.
See more: Javascript
i have a inner function and i call its with setTimeout.but It will not run.
what's my wrong
thank you

my code is :
<!DOCTYPE html>
<html lang="en" xmlns="">
    <meta charset="utf-8" />
    <script type="text/javascript">
        function Overrideablefunc() {
            this.runfunc=function () {
                document.getElementById('txt').value = Date().substring(0, 24);
                setTimeout(this.runfunc, 1000);
        function runnewfunc() {
            var a=new Overrideablefunc()
    <input type="button" value="Run" onclick="runnewfunc()"/><br />
    <input type="text" id="txt" style="width:400px"/>
Posted 10-Dec-12 3:13am
Please don't post non-answers as "solution". It can give you abuse reports which eventually may lead to cancellation of your CodeProject membership.
Comment on any posts, reply to available comments, or use "Improve question" (above).
Also, keep in mind that members only get notifications on the post sent in reply to there posts.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Overrideablefunc now acts like an object, you have to create an instance of it and then you can call runfunc

var override = new Overrideablefunc();
Sina asefi 10-Dec-12 11:21am
first thank you for your response
is it mean i should call my function with :

var overrd = new Overrideablefunc()
setTimeout(overrd.runfunc, 1000);

thank you

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 10 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100