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 9007645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:44:46+00:00 2026-06-16T01:44:46+00:00

I have this code which works fine in a test page… Javascript: function myFunction()

  • 0

I have this code which works fine in a test page…

Javascript:

function myFunction() {
    var x = document.getElementById("tarea"),
        nameInput = document.getElementById('name'),
        classInput = document.getElementById('class');

    var lines = x.value.split('\n');
    var name = lines[0].substring(5);
    var grade = lines[1].substring(6);

    nameInput.value = name;
    classInput.value = grade;
}

HTML:

<textarea rows="4" cols="50" id="tarea" onblur="myFunction()"></textarea>

Now I want to add the onblur functionality to a preexisting page using Greasemonkey.

But, I don’t know how can I use the onblur Javascript event in Greasemonkey. I’ve searched but couldn’t find any example of Greasemonkey using onblur.

  • 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-06-16T01:44:48+00:00Added an answer on June 16, 2026 at 1:44 am

    Use addEventListener() (plain javascript) or jQuery’s .on() (more robust approach).

    Plain JS:

    // ==UserScript==
    // @name     _YOUR_SCRIPT_NAME
    // @include  http://YOUR_SERVER.COM/YOUR_PATH/*
    // @grant    GM_addStyle
    // ==/UserScript==
    /*- The @grant directive is needed to work around a design change
        introduced in GM 1.0.   It restores the sandbox.
    */
    
    var targInput = document.getElementById ("tarea");
    targInput.addEventListener ("blur", myFunction, false);
    
    function myFunction () {
        ... ...
    }
    

    jQuery (recommended), note the @require:

    // ==UserScript==
    // @name     _YOUR_SCRIPT_NAME
    // @include  http://YOUR_SERVER.COM/YOUR_PATH/*
    // @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
    // @grant    GM_addStyle
    // ==/UserScript==
    /*- The @grant directive is needed to work around a design change
        introduced in GM 1.0.   It restores the sandbox.
    */
    
    $(document).on ("blur", "#tarea", myFunction);
    
    function myFunction () {
        ... ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, which works fine: <input type=button name=btnHello value=Hello onclick=Test();/> and
I have this code which compiles and works as expected: class Right {}; class
I have this code in my cfm, which works <cfif not StructIsEmpty(form)> <cfset larray
I have this code which is called at an onChange event of an function
Say I have this repeater which makes use of a public function called Test
I have the below code which loads the #special from my root page. This
So I have the following code: var element = document.getElementById(myCanvas); var width = element.width;
So, I have the code below which works fine when entered into Google's Rich
I have this code which adds a x number of views to a Multiview
I have this code which does the trick: #include <stdio.h> int main() { int

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.