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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:52:02+00:00 2026-05-15T10:52:02+00:00

My site has an iframe which is dynamically populated with html content. The html

  • 0

My site has an iframe which is dynamically populated with html content. The html often contains named anchors, which work fine in IE/Chrome but in Firefox it reopens the entire page within the iframe.

Here’s an example: load the page in firefox, scroll to the bottom of the iframe, click the “back to top” link, and you will see what I am talking about.

<html><head></head><body onload="setFrameContent();"><script>

var htmlBody = '<html> <head></head> <body>' +
'<a name="top"><h1>top</h1></a>' +
'<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>' +
'<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>' +
'<a href="#top">back to top</a></body> </html> ';

function setFrameContent(){
    if (frames.length > 0) {
        var d = frames[0].document;
        d.open();
        d.write(htmlBody);
        d.close();
    }
}

</script>
<h1>Here's an iframe:</h1>
<iframe id="htmlIframe" style="height: 400px; width: 100%"><p>Your browser does not support iframes.</p></iframe>
</body></html>

Any ideas?

  • 1 1 Answer
  • 1 View
  • 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-15T10:52:02+00:00Added an answer on May 15, 2026 at 10:52 am

    I had the same problem and found this workaround.

    <html>
    <head>
    <script>
    var htmlBody = '<html> <head></head> <body>' +
    '<a id="top"><h1>top</h1></a>' +
    '<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>' +
    '<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>' +
    '<a href="javascript:parent.gotoAnchor(\'top\')">back to top</a></body> </html> ';
    
    function setFrameContent(){
        if (frames.length > 0) {
            var d = frames[0].document;
            d.open();
            d.write(htmlBody);
            d.close();
        }
    }
    
    function gotoAnchor(id)
    {
        var el = null;
        el = window.frames['myiframe'].document.getElementById(id);
        window.frames['myiframe'].scrollTo(0,el.offsetTop);
    }
    </script>
    </head>
    <body onload="setFrameContent();">
    <h1>Here's an iframe:</h1>
    <iframe name="myiframe" id="htmlIframe" style="height: 400px; width: 100%"><p>Your browser does not support iframes.</p></iframe>
    </body>
    </html>
    

    Hope this helps.

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

Sidebar

Related Questions

My site has quite a deep navigation structure and quite often it looks like
My asp.net site has to run on several client servers. It's working fine on
I have a site that has a simple HTML button in a form. All
I have a page in a site that contains an iframe with a form
hallo all i have a site which has a very big scroll on it,
I am working with an asp.net 2.0 site (call it site 1) which has
I have iframe in the site which acts as an internal browser. I know
My site has a drop-down menu built in CSS and JavaScript that drops down
Our site has multiple wizards where various data is collected over several pages, and
Recently our site has been deluged with the resurgence of the Asprox botnet SQL

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.