Examples‎ > ‎

IE Compatibility View

By default Browser instance displays web pages in IE 7 Compability View. If the environment where JExplorer is running has installed MS IE 9 and you want that JExplorer displays web pages with enabled IE9 Compability View, then you need to invoke the following line before you create any Browser instance:

Browsers.turnOnCompatibilityMode(Browsers.getIEVersion());

The full sample that demonstrates how to use this functionality is the following:

import com.jniwrapper.win32.ie.Browser;
import com.jniwrapper.win32.ie.Browsers;

import javax.swing.*;
import java.awt.*;

/**
 * This sample creates browser added to a Swing container.
 */
public class CreateBrowserSample {
    public static void main(String[] args) {
        // [Ikryanov] Sets compatibility mode to the installed IE version.
        Browsers.turnOnCompatibilityMode(Browsers.getIEVersion());

        Browser browser = new Browser();

        JFrame frame = new JFrame("JExplorer - Create Browser Sample");
        frame.setSize(700, 500);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.getContentPane().add(browser, BorderLayout.CENTER);
        frame.setVisible(true);

        browser.navigate("http://www.google.com");
    }
}