Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4610906
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:11:47+00:00 2026-05-22T01:11:47+00:00

This is my code : function mark() { alert("This is a test box.."); }

  • 0

This is my code :

function mark()
{
    alert("This is a test box..");
}

setTimeout("mark()",5000);

Error : Function mark() is not found !!

There is some other issue.. as it works on http://jsfiddle.net/russcam/6EXa9/ but its not working in my application.. so can you help me debug this ?

What else can be the reason.. By the way I am running this inside a GreaseMonkey script !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:11:48+00:00Added an answer on May 22, 2026 at 1:11 am

    If you are using GreaseMonkey, any functions you define are sandboxed by GM and not available in the main window.
    When you use any of the native functions however, like setTimeout or alert, they are called in the context of the main window e.g;
    when you call setTimeout you are actually calling window.setTimeout()

    Now the function you have defined, mark doesn’t exist in the main window and what you are asking setTimeout to do is evaluate the string ‘mark()’. When the timeout fires
    window.eval( 'mark()' ) is called and as discussed, window.mark is not defined. So you have a couple of options:

    1) Define mark on the window object. GM allows you to do this through the unsafeWindow object like this:

    unsafeWindow.mark = function(){}
    setTimeout( 'mark()', 10 );        //this works but is ugly, it uses eval
    

    2) Pass a reference to the local mark to setTimeout:

    function mark(){}
    setTimeout( mark, 10 );        //this works too but you can't send parameters
    

    But what if you need to send parameters?
    If you have defined your function on the main window, the eval method will work (but it is ugly – don’t do it)

    unsafeWindow.mark2 = function( param ) {
        alert( param )
    }
    setTimeout( 'mark2( "hello" )', 10 ); //this alerts hello
    

    But this method will work for functions with parameters whether you have defined them on the main window or just in GM
    The call is wrapped in an anonymous function and passed into setTimeout

    setTimeout( function() {
        mark2( "hello" )
    }, 10 );                              //this alerts hello
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code $(#loading).ajaxStart(function() { alert(start); $(this).show(); }); in my mark-up <div style=text-align:center;><img id=loading src=../images/common/loading.gif
This code function LoadContent(Id) { alert('Controls/Network/NetworkDetail.aspx?' + rnd() + '&CtlId=' + Id); $.get('Controls/Network/NetworkDetail.aspx?' +
View this code: function testprecision(){ var isNotNumber = parseFloat('1.3').toPrecision(6); alert(typeof isNotNumber); //=> string }
With this code function someFunction(classParam:Class):Boolean { // how to know if classParam implements some
Hello I get a weird error in this code: function validateForm(aform) { var s=;
I have just come across this code: function test(){ //... if ( $profilerule ==
i have this code $(function() { $('#ans_vote a span').click(function(){alert('working');return false;});}); and this html <div
This code does not function as expected: // $field contains the name of a
I found this code: !function () {}(); What is the purpose of the exclamation
I have this code: function submitTwice(f){ f.action = 'http://mydomain.com/threevideopage.php'; f.target='name'; f.submit(); } I left

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.