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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:54:23+00:00 2026-05-23T19:54:23+00:00

In Firefox 3 and later (and probably older versions), selecting content within an iframe

  • 0

In Firefox 3 and later (and probably older versions), selecting content within an iframe always seems to use the grey selection background colour used for a document that doesn’t currently have focus, even if the iframe does have focus. The only exception I have been able to find is when the content within the iframe is editable. This is not the case in other browsers. Here’s an example illustrating this:

http://jsfiddle.net/97Vjz/

This unfortunately prevents styling the selection within an iframe using the ::-moz-selection CSS pseudo-element because it only applies to non-grey selections:

http://jsfiddle.net/YYXSY/1/

My question is: is it possible to prevent an iframe’s selection being grey in Firefox without using contenteditable / designMode?

UPDATE

This only seems to happen on dynamically written iframes: using a separate file and the src attribute solves the problem. However, I do need it to work with dynamically written iframes.

  • 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-23T19:54:24+00:00Added an answer on May 23, 2026 at 7:54 pm

    I just tried to reproduce the problem with a “real” page as iframe content and then it works like you want: blue colored selection! (FF 5.0)

    see: http://jsfiddle.net/97Vjz/8/

    It seems only generated content has this problem, so you could make a page (php/asp(x)) that generates the content for you to circumvent the problem.

    Another solution to use javascript generated content is to load it with src="javascript:'<html />'" (actually this is Tim’s own solution from the comments below.)

    A simple example script: http://jsfiddle.net/97Vjz/9/

     iframe.src='javascript:\'<html><body>' + content + '</body></html>\'';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firefox and seems to render a hyphen followed by &nbsp; differently to other browsers.
I found out IE has different behavior vs Firefox when I use this $('head').prepend('');
I want to run some application in background and later kill it by pid.
Probably this is a basic stuff, but better learn now then later. What i'm
I have page with an iframe. Iframe content comes from other domain, but I
The issue I have only happens in the later additions of Firefox. I've checked
Firefox 3.5 does not allow creating java OBJECT tag with Javascript (document.write)? this technique
Firefox requires xhtml extension for mathml but IE will not display pages with xhtml
Firefox 3 now stores bookmarks in a Sqlite file called profiles.sqlite. This file is
Firefox recently blacklisted the plugin that allows xbaps to work in firefox This is

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.