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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:18:22+00:00 2026-05-23T13:18:22+00:00

I’m currently developing a firefox plugin. This plugin has to handle very crappy website

  • 0

I’m currently developing a firefox plugin. This plugin has to handle very crappy website that is really incorrectly formatted. I cannot modify these websites, so I have to handle them.

I reduced the bug I’m facing to a short sample of html (if this appellation is appropriate for an horror like this) :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Some title.</title>
    <!-- Oh yes ! -->
    <div style="visability:hidden;">
        <a href="//example.com"> </a>
    </div>

<!-- If meta are reduced, then the bug disapears ! -->
<meta name="description" content="Homepage of Company.com, Company's corporate Web site" />
<meta name="keywords" content="Company, Company & Co., Inc., blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla" />
<meta http-equiv="Content-Language" content="en-US" />
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>

</head>
<body class="homePage">

<div class="globalWrapper"><a href="/page.html">My gorgeous link !</a></div>

</body>

</html>

When opening the webpage, « My gorgeous link ! » if displayed and clickable. However, when I’m exploring the DOM with Javascript into my plugin, everything behaves (DOM exploration and innerHTML property) like the code was this one :

<html>
<head>
<title>Some title.</title>
    <!-- Oh yes ! -->
    </head><body><div style="visability:hidden;">
        <a href="//example.com"> </a>
    </div>

<!-- If meta are reduced, then the bug disapears ! -->
<meta name="description" content="Homepage of Company.com, Company's corporate Web site">
<meta name="keywords" content="Company, Company &amp; Co., Inc., blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla, blablabla">
<meta http-equiv="Content-Language" content="en-US">
</body>
</html>

So, when exploring the DOM within the plugin, the document is somehow fixed by firefox. But this fixed DOM is inconsistent with what is in the webpage. Thus, my plugin doesn’t behave as expected.

I’m really puzzled with that issue. The problem exists in both firefox 3.6 and firefox 4 (didn’t tested firefox 5 yet). For example, reducing the meta, will fix the issue.

Where does this discrepancy come from ? How can I handle it ?

EDIT: With the answer I get, I think I should be a little more precise. I do know what firefow is doing when modifying the webpage in the second code snippet. The problem is the following one : « In the fixed DOM that I get into my plugin, the gorgeous link doesn’t appear anywhere, but this link is actually visible on the webpage, and works. So the DOM I’m manipulating, and the DOM in the webpage are different – they are fixed in a different manner. » . So where does the difference come in the fixing behaviour, and how can I handle that, or, in other terms, how can I be aware, in my plugin, of the existance of the gorgeous link ?

NB: Exploring the DOM with firebug show a different DOM from what I’m getting in my module. Both DOM are fixed by firefox, but in a different manner. I do get the DOM like this :

 var html = browser.contentDocument.documentElement;
 // Then, for example :
 html.getElementsByTagName('a'); // Returns only the a element in the header. On the webpage, only the a in the body appears.

DOM exploration with firebug show that the div and a within the header are removed, which is a different behaviour.

EDIT² : The code in my plugin is ran after the page loading end, by this mecanism :

gBrowser.addTabsProgressListener({
    onStateChange: function(aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
        if( (aStateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP) ) {
            // Some operations including the DOM parsing here
        }
    }
});
  • 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-23T13:18:23+00:00Added an answer on May 23, 2026 at 1:18 pm

    I tried to reproduce your issue and failed – everything seemed to work fine in Firefox 5. My mental powers tell me that you are trying to access the document before it finished loading. That’s why you need a lengthy meta tag, the document body downloads in two network packets then and you are looking at the document when only the first packet has been received. Wait for the DOMContentLoaded event before accessing the document. Or, if you are using a progress listener, wait for onStateChanged call with STATE_STOP and STATE_IS_DOCUMENT flags set.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from

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.