It seems something has changed, because I'm sure this worked before. I'm trying to track down the specific changes and I'll update this post when I get more details. I'm able to reproduce this on my work machine as well as my Tablet PC. The version of Internet Explorer is same on both machines: 6.0.2800.1106.xpsp2.030422-1633.
It seems when setting properties or calling certain functions in an HREF via inline Javascript, Internet Explorer evaluates the function and then renders the current screen with the results of the function.
Each of the following links work.
<a href="javascript:window.alert('test');">Dummy</a> <a href="javascript:function f() { document.all['id'].style.display = 'none'; } f();">Inline</a> <a href="#" onclick="javascript:document.all['id'].style.display = 'none';">OnClick</a>
The following, however, do not. The return value of the property or method replaces the current window's contents and the inline JScript becoming the title of the page.
<a href="javascript:document.all['elementId'].style.display = 'none';">Inline declaration</a> <a href="javascript:window.open('somePage.aspx','windowName','');">Open new window</a>
I don't know if this is new behavior based on some hotfix or something, expected behavior, or just something I haven't noticed before now - though somehow I can't imagine it is the last.
Demo
Dummy | [Inline](javascript:function f() { document.all['DemoId'].style.display = 'none'; } f();) | OnClick | [Straight Inline](javascript:document.all['DemoId'].style.display = 'none';) | Open new window
This is the demo block to be hidden and shown.
Quite curious.
Has anyone else seen anything similar? As I said, as I investigate more, I'll keep this updated in case it helps anyone else.
