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 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

What Firefox add-ons do you use that are useful for programmers?
In Firefox a Reload seems to reload everything while on IE the Refresh reloads
In Firefox...... <div id=container style=overflow:scroll; width:400px; height:500px> <div id=content style=height:500px; width:800px/> </div> The container
Im making firefox extension. One function stores value in every tab, to use it
Firefox 3 has introduced a new behavior in which line-height, when unset, differs from
In Firefox you can enter the following into the awesome bar and hit enter:
In Firefox and Safari, pages that are centered move a few pixels when the
In Firefox when you add an onclick event handler to a method an event
In firefox, I have the following fragment in my .css file tree (negative){ font-size:
How can I convince Firefox (3.0.1, if it matters) to send an If-Modified-Since header

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.