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

The Archive Base Latest Questions

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

I am writing a Firefox addon that allows for annotating a webpage by adding

  • 0

I am writing a Firefox addon that allows for annotating a webpage by adding a div/iframe element to the page. My addon code is able to put the div or the iframe in place, but it is unable to set the source of the iframe or the innerHTML of the div. Is there some security restriction that prevents me from setting the innerHTML of a div or the src of an iframe? Here is the code inside my addon.

    onPageLoad: function(aEvent) {
    var doc = aEvent.originalTarget;

    var q = "";
            q = getRequestParameter(doc.location.search,"q");
            if(debug) Firebug.Console.log("query string =" + q);
            if(q!="" && q!=undefined) { 
                //To Check for target type
                //Firebug.Console.log(aEvent.originalTarget.nodeName);

            var n = document.createElement("div");      
            n.style.position = "fixed";     
            n.style.padding ="10px";
            n.style.backgroundColor ="gray";
            n.style.bottom="0";
            n.style.zIndex = "99" ;
            n.style.width ="250px";
            n.style.height="320px";
            n.style.right="10px";
            n.style.overflow="visible";

            //gBrowser.contentDocument.body.appendChild(n);
            var i = document.createElement("iframe");
            i.style.height="300px";
            i.style.width="230px";
            i.style.zindex="999";
            i.id = "rowzSearchIFrame";      
            i.src="http://annotator.com?webpagequery="+q;
            i.name ="rowzSearchIFrame";
            n.appendChild(i);

            gBrowser.contentDocument.body.appendChild(n);
            //content.document.body.appendChild(n);     
            document.frames['rowzSearchIFrame'].location.href = 'http://annotator.com?webpagequery='+q;
            alert(document.frames['rowzSearchIFrame'].id);

            document.frames['rowzSearchIFrame'].location.href = 'http://annotator.com?webpagequery='+q;

            document.getElementById('rowzSearchIFrame').setAttribute('src','http://annotator.com?webpagequery='+q);
            content.document.getElementById('rowzSearchIFrame').setAttribute('src','http://annotator.com?webpagequery='+q);


            document.getElementById('rowzSearchIFrame').src = 'http://annotator.com?webpagequery='+q;
            content.document.getElementById('rowzSearchIFrame').src = 'http://annotator.com?webpagequery='+q;
}

My code is able to put the div and the iframe in place with all the right CSS but it cannot set the src of the iframe or the innerHTML of the iframe.

As you can see, I have tried all possible mechanisms of setting the iframe src. The script is just unable to do this. Please help!

  • 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-23T01:32:19+00:00Added an answer on May 23, 2026 at 1:32 am

    Your onPageLoad has to be somewhere in overlay otherwise you would’ve not been able to use gBrowser. If that’s the case your document.createElement won’t work, since that’s chrome window.

    It might work with doc.createElement or gBrowser.contentDocument.createElement. I haven’t tried but from what I can see you’re trying to create element on one document and append it to another.

    Adding an edit for sake of completing this answer. The changes made to the code as per this answer were as follows (Please compare with posted code to see the difference)

    onPageLoad: function(aEvent) {
    var doc = aEvent.originalTarget;
    
    var q = "";
            q = getRequestParameter(doc.location.search,"q");
            if(debug) Firebug.Console.log("query string =" + q);
            if(q!="" && q!=undefined) { 
                //To Check for target type
                //Firebug.Console.log(aEvent.originalTarget.nodeName);
    
            var n = doc.createElement("div");      
            n.style.position = "fixed";     
            n.style.padding ="10px";
            n.style.backgroundColor ="gray";
            n.style.bottom="0";
            n.style.zIndex = "99" ;
            n.style.width ="250px";
            n.style.height="320px";
            n.style.right="10px";
            n.style.overflow="visible";
    
            doc.body.appendChild(n);
    
            var i = document.createElement("iframe");
            i.style.height="300px";
            i.style.width="230px";
            i.style.zindex="999";
            i.id = "rowzSearchIFrame";      
            i.src="http://annotator.com?webpagequery="+q;
            i.name ="rowzSearchIFrame";
            n.appendChild(i);
    
            gBrowser.contentDocument.body.appendChild(n);
            //content.document.body.appendChild(n);     
            document.frames['rowzSearchIFrame'].location.href = 'http://annotator.com?webpagequery='+q;
            alert(document.frames['rowzSearchIFrame'].id);
    
            document.frames['rowzSearchIFrame'].location.href = 'http://annotator.com?webpagequery='+q;
    
            document.getElementById('rowzSearchIFrame').setAttribute('src','http://annotator.com?webpagequery='+q);
            content.document.getElementById('rowzSearchIFrame').setAttribute('src','http://annotator.com?webpagequery='+q);
    
    
            document.getElementById('rowzSearchIFrame').src = 'http://annotator.com?webpagequery='+q;
            content.document.getElementById('rowzSearchIFrame').src = 'http://annotator.com?webpagequery='+q;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a Firefox add-on that do something after the webpage is completely loaded.
I am writing a Firefox addon for Firefox 4 which allows you to create
I am writing a Firefox addon and it opens a page in the addon
I am writing a firefox extension that intercepts the XMLHttpRequest before the page gets
I am writing a FireFox add-on that displays webpages from my server as control
I'm writing a Firefox Addon and I was wondering if I could take advantage
What are some resources for getting started writing a Firefox Addon? Is there an
I am writing a Firefox extension. I would like to search the current webpage
I'm writing a Firefox extension that needs to know what the username of the
I'm writing a Firefox extension that's to be used in house. Basically, I need

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.