Abrir un popup desde el «href» de un enlace

Hoy me he encontrado con un problema que parecía una tontería pero que al final me ha costado un rato encontrar la solución.

El problema es que estaba usando un componente javascript que «pinta» un menú. Este componente recibe una matriz de N dimensiones que representan los menús y submenus.

Simplificando, este array recibe por cada elemento del menú el texto a mostrar y la URL donde lleva esa opción de menú. Finalmente el componente genera algo de este estilo:

TEXTO

El problema ha surgido cuando me ha surgido la necesidad de que uno de esos enlaces abriese un popup, en vez de redirigirnos a una URL.

En un entorno normal sería fácil porque bastaría con hacer algo de este estilo:

TEXTO

Pero el componente no me permitía meter código en el «onclick» así que la opción era jugar con el parámetro «URL» que le pasaba para conseguir abrir el popup.

He probado varias opciones:

1. TEXTO

2. TEXTO

3. TEXTO

...

Y conseguía abrir el popup pero luego la página se recargaba y mostraba simplemente «[OBJECT], con lo que no valía la solución. Por mucho «return false;» que metiese.

Al final la solución ha sido escribir esto:

TEXTO

Open a popup from the «href» of a link

Today I found a problem that seemed silly but ultimately cost me a while to find the solution.

The problem is I was using a javascript component that «paints» a menu. This component receives a N dimensional matrix representing the menus and submenus.

Simplifying, this array receives for each menu item text to display and the URL where it has that option menu. Finally, the component generates something like this:

TEXT

The problem has come when I need has arisen that one of those links would open a popup, instead of redirecting to an URL.

In a normal environment it would be easy enough to do something like this:

TEXT

But the component does not allow me to put code in the «onclick» so the choice was to play with the parameter «URL» was wrong for opening the popup.

I tried several options:

1. TEXT

2. TEXT

3. TEXT

...

And managed to open the popup but then the page is reloaded and showed simply «[OBJECT], so it was not worth the solution. Much» return false; «that poking.

In the end the solution has been to write this:

TEXTOpen a popup from the "href" of a link

Cómo evitar que se active el modo compatibilidad de IE

Desde la versión 8 de Internet Explorer existe la posibilidad de que renderize las páginas emulando a la versión 7. En el caso de la versión 9 puede emular a las dos versiones anteriores.

Esto que puede venir muy bien para webs viejas, supone un quebradero de cabeza en algunas ocasiones.

Llevo un par de días volviéndome loco con el siguiente problema:

Estoy usando un plugin de jQuery que me he creado. Este plugin pinta una especie de menú y posiciona los elementos de forma absoluta. Esta posición se calcula dinámicamente.

En el caso de IE7 ese cálculo he de hacerlo distinto así que tengo una parte del código que detecta la versión de navegador y dependiendo de si es la 7 o mayor, hace una u otra cosa.

El problema viene porque al desplegar este plugin en la web, que pertenece a una intranet, automáticamente el navegador (Internet Explorer 9) se configura para procesar el documento como si fuese el 7, pero sigue identificandose como el 9.

De esta manera desde el código recibo que es la versión 9 y actuo en consecuencia, pero como está tratando el documento como la versión 7, pues se ve todo mal. Si no me equivoco se comporta así por estar abriendo una web de una intranet.

Esto podemos verlo dándole a F12 en el Internet Explorer.

Existen directivas para obligar a que IE emule una versión anterior, pero lo que yo quiero es todo lo contrario, que se ejecute con la versión 9, que es realmente la que es.

Y tras mucho buscar, esta es la directiva que hay que meter dentro del HEAD de la página.

<meta http-equiv="X-UA-Compatible" content="IE=7,8,9" />

How to avoid triggering IE compatibility mode

Since the Internet Explorer version 8 there is the possibility that pages renderize emulating version 7. For version 9 can emulate the two previous versions.

This can come in handy for old sites, is a headache sometimes.

I have a couple of days going crazy with the following problem:

I’m using a jQuery plugin that I’ve created. This plugin looks a kind of menu elements positioned absolutely. This position is dynamically calculated.

For this calculation IE7 I do differently so I have a piece of code that detects the browser version and depending on if it’s 7 or greater, for one thing or another.

The problem comes because to deploy this plugin on the web, which is an intranet, the browser automatically (Internet Explorer 9) is configured to process the document as if the 7, but still identifying themselves as 9.

In this way from the receipt code is version 9 and acted accordingly, but as is treating the document as version 7, it looks all wrong. If I’m not mistaken behaves well to be opening an intranet web.

We can see this giving F12 in Internet Explorer.

There are directives to force IE to emulate a previous version, but what I want is the opposite, to run with version 9, which is really what it is.

And after much searching, this is the policy that you have to put into the HEAD of the page.

<meta http-equiv="X-UA-Compatible" content="IE=7,8,9" />