开发者

IE9: Get current url from command bar button - old method broken?

I add a button to the Internet Explorer command bar. When the user clicks it, an app is launched with the current browser URL as parameter. However, this no longer works in IE 9.

My button executes code like this:

<script language="JavaScript">
var shell = new ActiveXObject('WScript.Shell');
shell.run('notepad.exe "' + window.e开发者_开发百科xternal.menuArguments.location + '"', 1, false);
</script>

window.external.menuArguments.location seems to be always empty. Is there another way to grab the current URL that may work with IE9?

Thanks.


I've been battling with the same issue in IE9. ie. window.external.menuArguments.location is always empty. This certainly wasn't the case in previous versions of IE. The solution I've found is:

var oWindow = window.external.menuArguments;
var oDocument = oWindow.document;
var url = oDocument.URL;  // also see URLUnencoded

HTH, Neville

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜