Archive

Posts Tagged ‘IE’

HowTo: Tell IE to use compatibility mode without editing your web pages

at http://www.mono-software.com/Mono/Pages/Discussion/dtopic/_YyUBIlx5kiqHaNqAQeltg/br-brake-bug-in-IE11-and-clipflair-text-editor/

one reads:

We are using Telerik’s rich text editor (RadEditor), and it seems that RadEditor has specific behaviour regarding insertion of break tags.

To circumvent this issue please try to add host header in ISS 7 (website level):

Name = "X-UA-Compatible"
Value = "IE=EmulateIE10"

Or, you can insert Html Meta tag on a PreRender event (of Page that uses RadEditor):

HtmlMeta meta = new HtmlMeta();

meta.Attributes.Add("http-equiv", "X-UA-Compatible");

meta.Attributes.Add("content", "IE=EmulateIE10");

Page.Header.Controls.Add(meta);

 

This is a very handy trick, one can open up a website at IIS console and open HTTP Response Headers node and then add the Name / Value pair X-UA-Compatible / IE=EmulateIE10 to force say Internet Explorer 11 to behave like Internet Explorer 10

To confirm it works, press F12 to show developer tools in IE11 and see at the right that it says “IE10” instead of “Edge” at the HTML engine selection dropdown list (compatibility mode).

 

Screenshot 2014-08-22 19.05.29

Fix: How to remove Trovigo.com, SearchProtect, restore Internet Options

Trovigo.com is an unwanted search engine hijacker that renders Internet Options of Windows / Internet Explorer inaccessible. To restore them on an older Windows XP installation, one way that I’ve found to work is to update Internet Explorer to a newer version, aka IE 8 (say via the embedded Windows Update facility or Microsoft Update website – http://update.microsoft.com)

The software is also probably related to a software (at least on the machine I was fixing) called "Search Protect", that is running a service and two other processes that one launches, that tries to stop you from killing it and from changing search engine option in the web browser. To remove that you can use Process Explorer from http://www.sysinternals.com:

  1. Right-click the SearchProtect service and select Suspend (do the same for the two other processes it uses) to freeze it (breaks into the process with the debugger).
  2. Right click the service node (that has the other two processes shown as children under it in the process tree) and select "Kill process tree".
  3. Go to %ProgramFiles% (usually C:\Program Files) using Windows Explorer address bar (or type this in Start/Run… dialog and press OK) and remove the folder "SearchProtect"
  4. Use free software like CCleaner (http://www.piriform.com) free edition (it has a tool to edit startup entries) or the really powerful Autoruns one to remove the now broken (since you deleted the software at step #3 references in various Windows settings that try to launch the SearchProtect software (Autoruns shows in yellow startup references to missing files, can right click and delete those entries).

Gotcha: must set document.location.hash only at end of page in Mozilla

I just came across a different behaviour between IE and Mozilla Firefox: scripts at the former seem to execute after the page has fully rendered, while the later they seem to execute when they’re met by the page parser or something like that.

The HTML script tag has a defer attribute for running scripts after page has rendered, but that is available only for script tags that load an external script, not for embedded scripts in the HTML page. So this seems like one of those different interpretations that usually plague "standards". 

So, at the following JSP code, I was creating a table of student entries with a named anchor (bookmark) at each of the entries (each named per student id), so that when coming back from another page to that one I could tell it to scroll down to a given student automatically.

The issue was that if I placed the script that set document.location.hash to the student id, then at IE it worked OK, but at Mozilla Firefox it just moved to the top of the page even though the URL at the address bar of the browser had the hash entry (e.g. #55555) at the end and would scroll down correctly if I pressed Refresh button there.

Moving the script to the end of the page made it work for both IE and Mozilla Firefox. Don’t you love HTML’s "debug everywhere"?

 

<%@ page contentType="text/html" session="true" pageEncoding="UTF-8" %>

<%
response.setHeader("Cache-Control", "no-cache, no-store"); //HTTP 1.1
response.setHeader("Pragma", "no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", -1); //prevents caching at the proxy server
%>

<%@ page import="javax.portlet.*" %>
<%@ page import="java.util.ResourceBundle" %>

<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>

<%
  RenderRequest renderRequest = (RenderRequest) request.getAttribute("javax.portlet.request");
  RenderResponse renderResponse = (RenderResponse) request.getAttribute("javax.portlet.response");
          

  String studentId = (String)renderRequest.getAttribute(Constants.JSP_RENDER_STUDENTID);
  if (studentId == null) studentId = "";

  <%
       for(int i = 0; i < proposalsCount_supervisor; i++) {
        IProposalListItem proposal = proposals_supervisor.getProposalListItem(i); 
   %>
  <a name="<%=proposal.getStudentId()%>"></a>
   <div class="dissertation_subsection<%=(i%2)%>">

     <div>
     ….

   <%}%>

….

<script type="text/javascript"> <%– MAKE SURE THIS IS PLACED AT THE END, ELSE IT WON’T WORK AT MOZILLA –%>
document.location.hash="<%=studentId%>"; //scroll to previously examined student
<%– alert(document.location.hash); –%>
</script>

HowTo: Save screenshot of a control hosted on a WinForm

I’m trying to automate grabbing of activity screenshots from ClipFlair Activity Gallery, but most command-line screen capturing tools, like SiteShoter and IECapt fail to get an image from Silverlight content (they get just a background color).

Some other opensource tool that I could tweek was ThumbPage, but  that didn’t support command-line and needed to disable Silverlight hardware acceleration in the webpage source (that is not define enableGPUAcceleration Silverlight param or set it to false) to grab the Silverlight content too in the image. This is probably because that tool was written in VB6 and must be using plain GDI instead of GDI+ or other newer graphics API, but I’m not sure if that’s the issue with the h/w acceleration.

So, I started making my own WinForms-based tool in Visual Studio. The following sample code is based on ArsenMkrt’s reply at StackOverflow, but this one allows you to capture a control in your form (my tool has a WebBrowser control in it and want to capture just its display). Note the use of PointToScreen method:

//Project: WebCapture
//Filename: ScreenshotUtils.cs
//Author: George Birbilis (http://zoomicon.com)
//Version: 20130820

using System.Drawing;
using System.Windows.Forms;

namespace WebCapture
{
  public static class ScreenshotUtils
  {

    public static Rectangle Offseted(this Rectangle r, Point p)
    {
      r.Offset(p);
      return r;
    }

    public static Bitmap GetScreenshot(this Control c)
    {
      return GetScreenshot(new Rectangle(c.PointToScreen(Point.Empty), c.Size));
    }

    public static Bitmap GetScreenshot(Rectangle bounds)
    {
      Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height);
      using (Graphics g = Graphics.FromImage(bitmap))
        g.CopyFromScreen(new Point(bounds.Left, bounds.Top), 
                         Point.Empty, bounds.Size);
      return bitmap;
    }

    public const string DEFAULT_IMAGESAVEFILEDIALOG_TITLE = "Save image";
    public const string DEFAULT_IMAGESAVEFILEDIALOG_FILTER = 
"PNG Image (*.png)|*.png|JPEG Image (*.jpg)|*.jpg|Bitmap Image (*.bmp)|
*.bmp|GIF Image (*.gif)|*.gif";

//*** NOTE: the string above is a single line, split it for posting here ***//

    public static SaveFileDialog GetImageSaveFileDialog(
      string title = DEFAULT_IMAGESAVEFILEDIALOG_TITLE, 
      string filter = DEFAULT_IMAGESAVEFILEDIALOG_FILTER)
    {
      SaveFileDialog dialog = new SaveFileDialog();

      dialog.Title = title;
      dialog.Filter = filter;

      return dialog;
    }

    public static void ShowSaveFileDialog(this Image image, 
                                          IWin32Window owner = null)
    {
      using (SaveFileDialog dlg = GetImageSaveFileDialog())
        if (dlg.ShowDialog(owner) == DialogResult.OK)
          image.Save(dlg.FileName);
    }

  }
}

Note the “using” clause above, it makes sure that the local variable g of type Graphics is Disposed immediately after the respective clause exits, instead of leaving any allocated resources for the garbage collector to handle. Plus the compiler makes sure the “g” variable isn’t use at the following code in that method by mistake (which could occur if you disposed it there by hand instead).

Having the Bitmap object you can just call Save on it:

private void btnCapture_Click(object sender, EventArgs e)
{
  webBrowser.GetScreenshot().Save("C://test.jpg", ImageFormat.Jpeg);
}

The above assumes the Garbage Collector (aka GC) will grab the bitmap, but maybe it’s better to assign the result of someControl.getScreenshot() to a Bitmap variable, then dispose that variable manually when finished, especially if you’re doing this grabbing often (say you have a list of webpages you want to load and save screenshots of them):

private void btnCapture_Click(object sender, EventArgs e)
{
  Bitmap bitmap = webBrowser.GetScreenshot();
  bitmap.ShowSaveFileDialog();
  bitmap.Dispose(); //release bitmap resources
}

 

Update:

Now WebCapture tool is ClickOnce-deployed from the web (also has nice autoupdate support thanks to ClickOnce) and you can find its source code at http://ClipFlair.codeplex.com.

Speaking of ClickOnce, I noticed that if at the autoupdate dialog shown when you launch the app from its desktop shortcut (and there’s a new version available) you press “Skip”, it won’t offer you this update anymore when you launch an app (I hope that when an even newer update is there it will prompt you), but you can override that behaviour by going to the installation page for your ClickOnce app (where you installed it from in the first place) and press the “Install” button there.

Fix: remove ‘optimized for Bing and MSN’ from IE titlebar

Seems some Microsoft software (probably Bing bar) version is changing Internet Explorer title bar to write “optimized for Bing and MSN”.

To remove this:

  1. Use Start/Run or Start/Find and type there regedit then press ENTER to launch the Registry Editor.
  2. At the tree on the left navigate to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
  3. At the right handside of the window right click the value “WindowTitle” and select “Delete” to restore the default “- Windows Internet Explorer” suffix on the IE titlebar
Categories: Posts Tags: , , , , , ,

Fix: embed Office & Acrobat Active Documents in IE WebBrowser control

Since the LvS desktop application (from Learning Via Subtitling project) uses Internet Explorer to embed Microsoft Office Word, Excel, PowerPoint and Adobe Acrobat PDF documents (among others), I added some useful info to the LvS download page on how to work around issues one may face in such a scenario:

If you don’t have Microsoft Office (or have very old Office versions like Office 95 or Office 97) and want to embed Word documents you should better also install:

To show .docx (Word 2007+) files if you use Office XP or Office 2003 or the free Word viewer you need to also install "Microsoft Office Compatibility Pack for Word, Excel, and PowerPoint File Formats" from: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=3

Office 2007 doesn’t show documents embedded in Internet Explorer by default (which LvS uses internally to host Active Documents), use FixIt button at following page to fix this: http://support.microsoft.com/?id=927009 

In LvS if you have Office 2007 without this fix you will see message "Type the correct address" when your unpacked activity folder contains Office files

To embed Adobe Acrobat files you need Adobe Acrobat or the free Adobe Acrobat Reader from: http://adobe.com/reader

If Adobe PDF files don’t show embedded and open up in separate window: Use Start/All Programs menu from the Windows Taskbar and run Adobe Reader application. Then go to its menu "Edit/Preferences…" and at the dialog that opens up, go to "Internet" and check "Display PDF in browser", then press OK (can then close Adobe Reader).

When such files open embedded you may be asked to open or save the file for each one – select open and DO check to not be asked again (since it gets very annoying).

Since this "not ask again" will be remembered for IE too, if you want to clear it later on see the following article: http://www.howtogeek.com/howto/windows-vista/reset-opensave-choice-for-internet-explorer-downloads-in-vista/

more IE9 RC issues – Tale of two Internet shortcuts

Can you spot any difference at the following two Internet shortcuts on my desktop?

image

I can’t either. Note that the two files have the same “name”, but different file extension (invisible when using default Windows Explorer folder view settings). The one uses “.url” (classic Internet Explorer webpage shortcut), while the other one, created by Internet Explorer 9 RC when I drag-dropped a page’s icon from the address bar onto my desktop, uses the file extension “.website”. That’s why although they seem to the user to have the same name, they can still co-exist on the same folder (the desktop).

However, there are important differences on how these two Internet shortcuts behave. If you open the .url one with IE9 RC you get the window at the 1st image shown below, whereas if you open the “.website” one, you get the window at the 2nd image shown below. Notice the difference on the address bar? The Back and Forward buttons now have a different color (they get their color from the page icon somehow, maybe calculating the dominant color or something from there) and there’s also the page icon showing up at the start of the address bar (can click on it to go back to this page if you’ve navigated away from it).

Note that when you drag-drop the webpage icon from IE9 RC address bar onto the desktop you also do notice a different behaviour (than you were used to) from IE9, in that it closes that page and opens it up in a new window, with that modified address bar, 2nd image as shown below.

imageimage

Right-clicking each of those two files (the .url and the .website ones), and selecting “Properties”, you get the displays shown below on the left and right sides respectively. You’ll notice that the “.url” file is called an “Internet Shortcut”, whereas the “.website” one is called a “Pinned Site Shortcut”.

image

Note that the “.url” file’s “Properties” action takes you directly to a tab other than the “General” one, called “Web Document” (a custom property page) with more info on the URL, a tab that is missing (I’d consider this a bug) from the “.website” file properties dialog. That way you can’t edit the URL from the properties dialog, neither can you set a “Shortcut key” for launching the shortcut using the keyboard.

image

Right-clicking the “.url” file and selecting “Send to > Notepad” (assuming you have installed “SendTo tools” or similar utility, or created a shortcut to “Notepad.exe” at your SendTo folder), you see the following contents:

[InternetShortcut]
URL=http://www.guardian.co.uk/commentisfree/cifamerica/2011/feb/14/useconomy-usemployment
IconFile=http://www.guardian.co.uk/favicon.ico
IconIndex=1

Right-clicking the “.website” file and selecting “Send to > Notepad” (assuming you have installed Send To tools or created a Notepad shortcut at your SendTo folder), you see the following contents:

[{000214A0-0000-0000-C000-000000000046}]
Prop4=31,The revenge of trickle-down economics | Richard Wolff | Comment is free | guardian.co.uk
Prop3=19,2
[InternetShortcut]
URL=http://www.guardian.co.uk/commentisfree/cifamerica/2011/feb/14/useconomy-usemployment
IDList=
IconFile=http://www.guardian.co.uk/favicon.ico
IconIndex=1
[{9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3}]
Prop5=8,Microsoft.Website.CF19EB85.7C0F63A3
[{A7AF692E-098D-4C08-A225-D433CA835ED0}]
Prop5=3,0
Prop2=65,2C0000000000000001000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF30000005900000085030000D4010000C6
Prop6=3,1

I find the new IE9 RC behaviour non-intuitive, esp. the action of closing old tab and popping up a new window when you drag-drop the page icon from the address bar onto the desktop. This violates the UI design principle of “least surprise” for the user.

Moreover it refreshes the page when doing that (which can result in loss of data if you were filling-in something online and hadn’t submitted yet – hope it does at least respect webpages that use closing event handler to warn the user they haven’t saved and allow them to cancel the page closing).

You can see more info on Pinned Site Shortcuts at http://msdn.microsoft.com/en-us/ie/dd797411 (as a reader of my previous blog post pointed out).

Categories: Posts Tags: , , , , ,

Bug: “The disk is full” at base.bundle.js of #NewTwitter

twitter-big-diskfull

Sometime ago I got the above error screen (after clicking on the error notice at the statusbar) on IE8/Vista at the new Twitter UI (aka #NewTwitter). Exactly what does “The disk is full.” error mean to say? Wonder if twimg.com (probably used to host images served by Twitter like avatar images) was itself running out of disk space and this was some error string returned via AJAX or if it’s some silly error message (maybe cause their code thought IE8 supports HTML5 local storage or something).

Maybe they’ve fixed it now, but in general even the classic Twitter UI didn’t seem to always play ok with IE8, e.g. Retweet didn’t always work (would see “Error on page” at the bottom) and you had to click on “x minutes ago” under a given status update to go to a page where you could retweet it…

Categories: Posts Tags: , , ,

Bug: Dragging webpage icon from IE8’s address bar onto desktop with CTRL pressed

You may already know that dragging current webpage icon from Internet Explorer 8 address bar onto the desktop creates a URL shortcut to that page on the web. However I just found out that holding down CTRL, this action creates a broken .htm file like the following one instead:

<BASE HREF=”http://msdn.microsoft.com/en-us/magazine/ee336122.aspx”&gt;

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http:/

Categories: Posts Tags: ,
%d bloggers like this: