[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1128
  • Last Modified:

IE MenuExt scripting problem

Hi,

We're trying to integrate IE with a document management package.

The plan is to add a reg key to HKCU\software...\Internet Explorer\MenuExt so that we could add 'Download file to Document Mangement' to the IE context menu for links.

We've added the key, and set it to point at a local html file that contains VBScript that will download the file, then ask a few questions before putting it into the documnet management system.
We've added this to MenuExt with a 'context' of 0x20 (Anchor), and if we right click on a URL in a web page, it appears and when selected runs the script. In the script. The script then grabs the URL using external.menuArguments.event.srcElement.href.

So, a URL in a page defined as:
<a href="www.someserver.com/docs/spec.doc">File Specification</a>
comes back to the script as www.someserver.com/docs/spec.doc. Everybodies happy. Everybodies dancing.

Except there's a fly in the ointment.

If the URL is based on an image, instead of text, for example:
<a href="www.someserver.com/docs/spec.doc"><img src="/Images/doc.gif"></a>
Then we don't get the option on the context menu, as it's a different context menu, the one for images. We've tried adding it in the image context, using 0x2 (Images) on the reg key. When we do this, we get the option, but when we grab external.menuArguments.event.srcElement.href in the script, we get www.someserver.com/Images/doc.gif, not www.someserver.com/docs/spec.doc (which is what we want).

Anyone got any ideas? Either for a different context for the reg key, or a different way of getting hold of the correct URL when we put it on the image context menu.

Cheers,

H.
0
Halibut
Asked:
Halibut
  • 2
1 Solution
 
RobSampsonCommented:
Hi, I'm not too sure, but try outputting the
srcElement.tagName

to make sure you're catching an "A" tag, because that will have an href attribute.

If you're catching something that is not an "A" tag (that is an "IMG" tag for example), try using
srcElement.parentNode.href

Regards,

Rob.
0
 
HalibutAuthor Commented:
Many thanks, Rob.

external.menuArguments.event.srcElement.parentNode.href was what I was looking for, in combination with a context of 0x2.

Cheers,

H.
0
 
RobSampsonCommented:
Oh yeah, true.  I forgot about the Context thing, which already defines which srcElement is being thrown at it anyway.....cool, glad it worked.

Regards,

Rob.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now