Best firefox questions in July 2011

Prevent selection being greyed out in iframe in Firefox without using contenteditable

9 votes

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.

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>\'';

Google Analytics snippet causes page refresh in Linux Firefox

8 votes

My company is using Google Analytics on our websites. We found a weird bug that only occurs on one computer. We didn't see the issue when we tried to reproduce it on another machine using the exact same version of Linux with the same version of Firefox.

Here's the issue: Whenever a page with the Google Analytics tracking code is loaded in Firefox for Linux, the page automatically refreshes after 60 seconds - always 60 seconds. My guess is that this is an issue related to the Analytics' tracking the visit duration.

Has anyone else experienced any issues with the Analytics snippet causing their webpage to reload? Any clue what causes this? One other person posted about the same issue on Google Analytics help, but they have yet to receive a response.

This issue just started happening about a week ago.

There, a guy says deleting cookie GASO may solve the issue.

The cookie GASO ( google analytics site overlay ) seems to be setted when viewing google in-page so that if you go on the website, the google analytics see the cookie GASO and open in-page on the website.

When I tested this cookie was deleted when closing in-page ( so I don't see why you would still have it if google analytics in-page is closed ), but since the google support link seems to say it's related to that, you might give it a try.