Question

I am working on an application where I am required to make legacy code, which has been designed primarily for Internet Explorer, work with Firefox.

The problem I have hit is iframes nested within a table structure do not expand to the full height of the table cell. Due to the size of the web application the decision has been made to create a JavaScript shim to address this issue instead of making mark-up changes. This shim will only be included on the page if the browser is Firefox as the problem does not exist within other browsers I have tested.

So my question is:

Using a classic ASP VBScript function how can I identify Firefox browsers, this should include any edge cases?

So far I have the following which checks the user agent for the string value "Firefox". Are there any cases where this would not work?

function IsFirefox()

    dim userAgent : userAgent = Request.ServerVariables("HTTP_USER_AGENT")
    dim locationOfFirefox : locationOfFirefox = InStr(1, userAgent, "Firefox", 1)

    IsFirefox = (locationOfFirefox > 0)

end function
Was it helpful?

Solution

According to a document from the Mozilla Foundation, Firefox must be identified by the user agent when it contains the string "Firefox/xyz" and does not contain the string "Seamonkey/xyz". More information:

https://developer.mozilla.org/en-US/docs/Browser_detection_using_the_user_agent

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top