Jump to content

Get active hyperlink ?

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
pokevitek

pokevitek

    Newbie

  • Members
  • PipPip
  • 21 posts
Hi, I want to write simple IE addon in form of adding context button to the IE. That is simple, you just create new registry entry. Acter clicking that button, you script is executed and can access parent window objects. My problem is, is there a wa yin javascript how to get URL of the hyperlink which is currently active? I mean, mouse is on it? Thanks.

#2
dbug

dbug

    Programmer

  • Members
  • PipPipPipPip
  • 155 posts
Here you can find some examples for various types of actions.

Basically you should specify that your new context-menu option is for anchors (setting 0x20 in Contexts value of the registry). And then you can access the selected link as shown (example taken from the previous web page):

    var aDestination = "http://www.google.com/search?q=cache:"

    var aWindow = window.external.menuArguments;

    var aDocument = aWindow.document;

    var anEvent = aDocument.parentWindow.event;

    var aLink = anEvent.srcElement;

    aWindow.open(aDestination + aLink);
aLink contains the url you want.

#3
pokevitek

pokevitek

    Newbie

  • Members
  • PipPip
  • 21 posts
You just help me A LOT. Thank you.