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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:17:08+00:00 2026-05-28T00:17:08+00:00

I would like to write a greasemonkey script to disable a div on a

  • 0

I would like to write a greasemonkey script to disable a div on a certain page.
On any given load of the page I don’t know where in the DOM the div will be but I know it’s always called <div id = "alertPanel"> ....</div>

How would I go about disabling this div?

My intial thoughts were something along the lines of:

var myDivs= document.getElementsByTagName('div');

for (i=0; i<myDivs.length; i++)
{

  if (myDivs[i].<get id property somehow> = "alertPanel")
     myDivs[i].style.visibility = 'hidden';
 }

but as you can tell I’m stuck at accessing the id property for an equality check.

Incidently, I’m using a text editor to write this – I guessing that a standard javascript editor would give an autocompletion list after typing in myDivs[i].

  • 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-28T00:17:09+00:00Added an answer on May 28, 2026 at 12:17 am

    If it has an id, you can use document.getElementById:

    var div = document.getElementById("alertPanel");
    

    Then if it exists, you can either remove it (probably a bad idea) or hide it:

    if (div) {
        div.style.display = "none"; // Hides it
        // Or
        // div.parentNode.removeChild(div); // Removes it entirely
    }
    

    Update: Re your comment on another answer:

    thanks for your answer. Does your statemt apply to a page with iframes too. The div in question is in an iframe. I’ve tried ypur solution and it didn’t work unfortunately. maybe a link to the page will help: tennis.betfair.com the div i want to disable is the one with id: minigamesContainer

    If the element is in an iframe, then you have to call getElementById on the document that’s in the iframe, since iframes are separate windows and have separate documents. If you know the id of the iframe, you can use document.getElementById to get the iframe instance, and then use contentDocument to access its document, and then use getElementById on that to get the “minigamesContainer” element:

    var iframe, div;
    iframe = document.getElementById("the_iframe_id");
    if (iframe) {
        try {
            div = iframe.contentDocument.getElementById("minigamesContainer");
            if (div) {
                div.style.display = "none";
            }
        }
        catch (e) {
        }
    }
    

    (The try/catch is there because of a potential security error accessing the content of the iframe; I don’t know Greasemonkey well enough to know whether the SOP applies to it. I tend to assume it doesn’t, but better safe…)

    If you don’t know the id of the iframe or if it doesn’t have one, you can just loop through all of them by getting them with document.getElementsByTagName and then looping:

    var iframes, index, iframe, div;
    iframes = document.getElementsByTagName("iframe");
    for (index = 0; index < iframes.length; ++index) {
        iframe = iframes[index];
        try {
            div = iframe.contentDocument.getElementById("minigamesContainer");
            if (div) {
                div.style.display = "none";
                break;
            }
        }
        catch (e) {
        }
    }
    

    References:

    • DOM2 Core
    • DOM2 HTML
    • DOM3 Core
    • HTML5 Web Applications APIs
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to write a greasemonkey script that given an xpath returns all
I'm trying to write a Greasemonkey script, and would like to use the jQuery
I am making a greasemonkey script and i would like a link to go
Would like to write a script to detect the file size of the target
I would like to write variable f into certain elements ( index ) of
I'm talking about something like GreaseMonkey but that would accept the script just as
I would like write a script in Powerbuilder 11.5 in order to read Excel
I would like to write Python script, which will get i.e. 100 news/texts from
I would like to write a setup script for my PHP application, which dose
I would like to write a program or script that would generate .vcproj and

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.