JavaScript: void(0), IE6, SWFAddress

908 Views Asked by At

Greetings,

We're about to launch a secured site (sorry, no URL) and have caught a rather esoteric bug in IE6 that I'm hoping someone might have encountered or be able to shed some light on. This only occurs when three factors are present:

  1. The browser is IE6 (it's a financial client, and that's their approved browser)
  2. SWFAddress is being used in the page, which is all Flash
  3. void(0) is called from a browser bookmark with the value set to a JavaScript string

If you're familiar with Instapaper's "Read Later" bookmarklet, which launches a popup window with a Read Later button to submit the URL you were viewing to their site to log, it's the same premise.

This works on any other URL in the parent window that I've tested. It only fails when the SWF updates the browser history/URL using SWFAddress, which is a requirement as that's the deep-link URL we're trying to capture with the bookmarklet tool.

As I understand it, the JavaScript string needs to end in void(0) so that the parent window does not navigate to the JavaScript string. This is typical of the old school application of JavaScript in an href attribute.

We're seeing two things:

  1. After the first time you open the new browser window with the JS code in the bookmark, SWFAddress no longer updates the browser history/URL bar.
  2. After you submit and close the new browser window, which has a form in it, subsequent opening of the window via the bookmark ignores the void(0) and redirects the parent window.

Here's the bookmark code:

javascript:var%20d=document;w=window,f='http://mydomain.com/popup?l=',l=d.location,e=encodeURI,p=e(l.href),u=f+p;s=p.split('/');if(s[3]=='p'||s[3]=='t')u=u+'&p='+s[5];w.open(u,'p','toolbar=0,menubar=0,directories=0,personalbar=0,resizable=0,status=1,width=300,height=460');void(0);

The Flash piece is managed by another vendor, so I have no control or insight into their code. I'm really just trying to float this issue to see if anyone has encountered such issues with this set of factors.

Thanks much, Mark

3

There are 3 best solutions below

1
On

Hello You can try this

<a href='#' onclick='document;w=window,f='http://mydomain.com/popup?l=',l=d.location,e=encodeURI,p=e(l.href),u=f+p;s=p.split('/');if(s[3]=='p'||s[3]=='t')u=u+'&p='+s[5];w.open(u,'p','toolbar=0,menubar=0,directories=0,personalbar=0,resizable=0,status=1,width=300,height=460');'>click to visit</a>
0
On

It looks like your bookmarklet has a few syntax errors and could be reduced a little bit more :

javascript:var%20f='http://mydomain.com/popup?l=',l=document.location,e=encodeURI,p=e(l.href),u=f+p,s=p.split('/');if(s[3]=='p'||s[3]=='t')u+='&p='+s[5];open(u,'p','toolbar=0,menubar=0,directories=0,personalbar=0,resizable=0,status=1,width=300,height=460');void(0);

You could also try to add return false; instead of void(0);

1
On

If you're using getURL() or navigateToUrl() then you need to know that it creates a conflict with SWFAddress. Check http://www.asual.com/blog/swfaddress/2007/05/18/swfaddress-bad-practices.html for explanation.