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

  • Home
  • SEARCH
  • 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 6860979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:28:37+00:00 2026-05-27T02:28:37+00:00

I use a site that looks like this: … <body> <iframe src=blabla/blabla…></iframe> </body> …

  • 0

I use a site that looks like this:

    ...
    <body>
    <iframe src="blabla/blabla..."></iframe>
    </body>
    ...

The iframe loads a different HTML file from the same domain; it has it’s own body

In Firebug, it looks like this:

    ...
    <body>
    <iframe src="blabla/blabla...">
    ...
    <body class="classname ">
    ...
    </body>
    </iframe>
    </body>
    ...

The problem is this: the site would be way easier to view, if I could add a second class name to the second body, like this:

    ...
    <body>
    <iframe src="blabla/blabla...">
    ...
    <body class="classname classname2">
    ...
    </body>
    </iframe>
    </body>
    ...

I do not own the domain, I just want to ‘remix’ the web content.

I tried stuff like this:

    // ==UserScript==
    // @name           descr
    // @namespace      http://localhost
    // @description    descr
    // @require       http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js
    // @include        http://web.site/sub.ab*
    // ==/UserScript==

    $("iframe").load(function(){
    alert(document.getElementById('frameid').contentDocument);

    });

They idea was to use

document.getElementById('frameid').contentDocument.document.getElementsByTagName('body')[0].addClass('classname2')

But it does not work. Tried the same using contentwindow, nothing again. Alert tells me there is a element specified: [object HTMLDocument] but when I type anything beyond that, like .document the alert becomes empty, or won’t show at all.

What am I doing wrong?

Edit: Not sure if this has anything to do with it, but I forgot to tell there are actually 2 iframes: one is being blocked by Adblocker, this is why I did not mention this before.

  • 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-27T02:28:37+00:00Added an answer on May 27, 2026 at 2:28 am

    In Greasemonkey it’s really easy. A GM script will fire on an iFrame, much like it would on the containing page.

    So, if you create a second GM script like this:

    // ==UserScript==
    // @name            descr, iFrame handler
    // @require         http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js
    // @include         http://IFRAME_SITE.COM/blabla/blabla...
    // ==/UserScript==
    
    $("body").addClass ('classname2');
    

    It will work with no fuss.

    Note that you can do everything with only one GM script, but that can get tricky if you’re not careful. Keep it simple, for now.

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

Sidebar

Related Questions

i have a web.config file that looks like this: <?xml version=1.0?> <configuration> <system.web> <compilation
I have a html table that looks something like this <table id=eventTable> <thead> <tr><th>#</th><th>Options</th></tr>
I've got a RewriteMap that looks like this: Guide 1 Mini-Guide 2 White Paper
I have some code that looks like this: <h3>Thursday Sep 10</h3> <ul>great stuff in
I'd like to create a webpage which looks like this: https://i.stack.imgur.com/GYEis.png I can't use
I'm looking at a domain registration site that looks like it uses jquery to
I have some javascript that looks like this: var sel = '<option value={value} {selected}>{name}</option>';
I have a route that looks like this: new { controller = ControllerName, action
I have a site that makes use of GET variables to determine what to
I have a site that I've developed that makes decent use of Javascript, 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.