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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:43:16+00:00 2026-06-18T15:43:16+00:00

Adding these two buttons using greasemonkey. I’ve tried reversing the order and it’s always

  • 0

Adding these two buttons using greasemonkey. I’ve tried reversing the order and it’s always the 2nd added button that works. The other button will not fire the onclick event.

// Add the click to chat button
mydiv             = document.getElementById("optionalJobinfoData");
var btn           = document.createElement("input");
btn.type          = 'button';
btn.value         = 'Click to Chat';
btn.onclick       = function() { window.open(chatURL); };
mydiv.innerHTML  += "<i>Notify Dispatch</i><br><i>(stuck on job)</i>&nbsp;&nbsp;";
mydiv.appendChild(btn);

// Credentials button
mydiv             = document.getElementById("optionalJobinfoData");
btn               = document.createElement("input");
btn.type          = 'button';
btn.value         = 'Credentials';
btn.onclick       = function() { window.open(credsURL); };
mydiv.innerHTML  += "<br><br><i>DSL Credentials</i> ";
mydiv.appendChild(btn);
  • 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-18T15:43:17+00:00Added an answer on June 18, 2026 at 3:43 pm
    // Add the click to chat button
    mydiv             = document.getElementById("optionalJobinfoData");
    var btn           = document.createElement("input");
    btn.type          = 'button';
    btn.id            = 'openChat';
    btn.value         = 'Click to Chat';
    mydiv.innerHTML  += "<i>Notify Dispatch</i><br><i>(stuck on job)</i>&nbsp;&nbsp;";
    mydiv.appendChild(btn);
    
    // Credentials button
    mydiv             = document.getElementById("optionalJobinfoData");
    btn               = document.createElement("input");
    btn.type          = 'button';
    btn.value         = 'Credentials';
    btn.id            = 'openCreds';
    mydiv.innerHTML  += "<br><br><i>DSL Credentials</i> ";
    mydiv.appendChild(btn);
    
    document.getElementById("openCreds").onclick = function() { window.open(credsURL); };
    document.getElementById("openChat").onclick = function() { window.open(chatURL); };
    

    Above should work fine. Problem is that innerHTML += basically recreate objects. And pointer to onclick function handler is lost because of that (type, value etc. are parts of HTML, but innerHTML can’t get pointer to a function for onclick)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've setup an own class(custom UIView). I'am adding two of these customViews to my
Action buttons are added to jqGrid columns using colmodel below. Column width 45 is
I have two questions. Before detailing these questions, I want to add I'm using
I am adding a button to an actionsheet. That's easy, but in my case
After adding these settings in web.config for increasing session timeout: <sessionState mode=InProc stateConnectionString=tcpip=127.0.0.1:42424 stateNetworkTimeout=240
I currently am adding some features to our logging-library. One of these is the
Is there a better way of adding a button at the bottom of a
I have two RichTextboxes on my page. I am using them as a Book
I am currently working on a site,that uses Sorgilla jquery jcarousel, there are two
I am following this example of a difference chart . I've added buttons on

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.