Re: Right click on text vs. right click on hyperlink
- From: "Larry" <larry328NOSPAM@xxxxxxx>
- Date: Wed, 20 Jul 2005 23:29:58 -0400
Thanks very much. There's a lot here and I will absorb it and get back
to you. In the meantime, to make it clearer what I want, below is the
htm source file that I want to modify. What this script does is allow
me to open in one step the editing page of any archive page in my blog.
(The software I currently have does not allow for this.) Here's the way
it works. I right click on an archive page in my blog, click a button
on the context menu called "Edit Entry," and it runs the htm file that
contains the below Windows script. The script extracts the url of the
web page, opens Word, copies the url into Word, then runs a macro in
Word called EntryEditPageOpen which changes the url of the archive page
into the url of the editing page for that that archive page, then runs
that url and opens the editing page.
Now what I want to do is to make this also work when I am not in the
archive page that I want to edit, but in another page (say the home
page) and am clicking on a hyperlink to that archive page. In that
event, I want the script to recognize that I have clicked on a hyperlink
instead of the text area of web page and to extract the url from the
hyperlink instead of (as in the other instance I described) extracting
the url of the current web page.
Now here's the script
<html>
<head>
<script language="VBScript"><!--
' Click in a blog archive page and click the button "edit entry &open"
and
' the editing page for that page will open.
' Now I need to modify this so that I can do the same thing for clicking
on a
' shortcut to an archive page.
' Added these two lines for purpose of opening e-mail.
Dim WSH
Set WSH = CreateObject ("WScript.shell")
Dim oWindow, oDocument, docAddress, oSelectRange
Set oWindow=window.external.menuArguments
Set oDocument=oWindow.document
docAddress=oDocument.URL
'docTitle=oDocument.Title
If docTitle = "" Then
docTitle = "(no document title)"
End If
'Set oSelect=oDocument.selection
'Set oSelectRange=oSelect.createRange()
'oSelectRange.execCommand("Copy")
Dim oWd, doc
On Error Resume Next
Set oWd = GetObject(, "Word.Application")
If TypeName(oWd) <> "Application" Then
Set oWd = CreateObject("Word.Application")
End If
' moving invisible thing here so that Word won't be seen if it's being
normalized.
oWd.Visible = False
Set doc = oWd.documents.add
' Make Word invisible so I don't see Word do its thing,
' which also seems to make the script work faster.
'oWd.Visible = False
oWd.Activate
' new line added to normalize window
oWd.WindowState = 0
oWd.Selection.TypeParagraph
oWd.Selection.TypeText(docAddress)
' run a macro that changes url of page into url of editing page
oWd.Run "EntryEditPageOpen"
oWd.ActiveDocument.Close wdDoNotSaveChanges
' Make Word visible again
oWd.Visible = True
--></script>
</head>
</html>
mayayana wrote:
> I am assuming that you want to do this
> in a webpage opened in Internet Explorer,
> so the code I posted is showing how to do
> it with the Internet Explorer Document Object
> model.
> Any page in IE is a document object. There is
> also an implied window object, where the document
> resides. In the document, every HTML tag is an
> Element. So you can access the page that way.
> Example: A IMG tag is an element. It's tagName
> property is "IMG". If a tag contains the IMG tag then
> that's its parentElement. You can find out and do just
> about anything you want to through that system.
>
> By the "click sub" I meant the click event sub for the
> document. There actually isn't any right-click sub but
> you can do it like this:
>
> Sub document_onmouseup()
> If (Document.parentWindow.event.Button = 2) Then '--right button.
> '-- right mouse up.
> Else
> '-- left mouse up.
> End If
> End Sub
>
> That sub would provide a way to catch all link
> clicks and deal with them.
> You can also do it per-link by giving an ID to the A tag.
> If you use something like:
> <A HREF="somewhere.com.index.html" ID="A1"></A>
>
> then you can catch the right- click with the onmouseup
> event of the tag itself by using the following sub in the
> HEAD of the page:
>
> Sub A1_onmouseup()
>
> Either way you need to handle events in order to catch
> the click. I'm not sure what you mean by the "application
> key" and "shortcut menu". You mean the context menu
> that shows when you right click? You need to catch the
> event. Either you would want to use the onkeypress or
> onkeyup events, or you could use the oncontextmenu
> event. The only problem with the latter is that it doesn't
> work in IE4. In IE5 and 6 you can actually block the context
> menu from showing by adding this:
>
> Function document_oncontextmenu()
> On Error Resume Next
> document_oncontextmenu = False
> End Function
>
> You can then show your own menu or message, or
> do something else, but it doesn't work in IE4 and
> I think it doesn't work in IE6 XP SP2. (I think Microsoft
> finally realized, to some extent, that they never should
> have let web masters control the browser functions in
> the first place!)
>
> You saids you wanted to do something when a link
> was clicked. If what you actually want to do is to take
> an action when the context menu shows then that's
> different. But whatever you want to do, you have to
> deal with the related events.
>
> The Document Object Model (DOM) is very complex
> and somewhat convoluted. It helps to have documentation,
> but the only complete and usable docs I know of are to
> have a local copy of MSDN. MSDN online is nearly useless
> for finding things and takes far too long to load if you need
> to jump around to a lot of pages. Ant the IE DOM is just
> too big to put into a normal help file.
>
> If you want to get more into it you could check this
> download:
> http://www.jsware.net/jsware/scripts.html#domed
>
> It might be of some use for reference. The download is
> a full scale "WYSIWYG" HTML editor powered only by
> VBScript in IE windows. The whole point of it is to
> demonstrate how to accomplish various things using
> the IE DOM.
>
> Sorry this answer is so rambling, but I'm not sure
> exactly what it is that you need to know.
> --
> > Also, you refer to a click event sub. I know click events from
> > forms in Word VBA. But what does that mean here? Is it a file
> > separate from the source code of the htm file?
> >
> >
> >
> > "Larry" <larry328NOSPAM@xxxxxxx> wrote in message
> > news:e86HffUjFHA.2904@xxxxxxxxxxxxxxxxxxxxxxx
> > >
> > > I'm happy to hear that this is possible to do. But is this code
> > > sufficient to set it up? What I mean is, does the script
> > > recognize
> > "A"
> > > as meaning that a hyperlink has been clicked on and "IMG" as
> > > meaning that an image has been clicked on?
> > >
> > > Also, what if I don't right click on the page, but simply press
> > > the application key on my keyboard which makes the shortcut menu
> > > appear?
> > If
> > > the focus is on the page would opening the menu via the
> > > application
> > key
> > > have the same effect as right clicking on the page? In other
> > > words, would the code read it as "Case Else," neither a
> > > hyperlink, nor an image, but just plain text?
> > >
> > > Thanks.
> > >
> > >
> > >
> > >
> > > "mayayana" <mayaXXyana1a@xxxxxxxxxxxxxxxx> wrote in message
> > > news:7FsDe.14331$aY6.11404@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > > > In the click event sub you can use something
> > > > like the following:
> > > >
> > > > sTag = window.event.srcElement.tagName
> > > >
> > > > Select Case sTag
> > > >
> > > > Case "A" 'link was clicked.
> > > >
> > > > Case "IMG"
> > > > if window.event.srcElement.parentElement.tagName = "A"
> > > > then '-- it's an image link
> > > > end if
> > > >
> > > > Case Else
> > > > '-- do code for non-tag.
> > > >
> > > > End Select
> > > >
> > > > --
> > > > --
> > > > Larry <larry328NOSPAM@xxxxxxx> wrote in message
> > > > news:#LA4Y#OjFHA.3936@xxxxxxxxxxxxxxxxxxxxxxx
> > > > > Is there a way that Windows script can tell whether the mouse
> > > > > has
> > > right
> > > > > clicked on the text area of a web page, or whether it has
> > > > > right
> > > clicked
> > > > > on a hyperlink on the webpage? I have a Windows script in an
> > > > > htm
> > > file
> > > > > that I want to behavior differently depending on whether the
> > > > > first condition or the second condition exists .
> > > > >
> > > > > Thanks,
> > > > > Larry
.
- Follow-Ups:
- Re: Right click on text vs. right click on hyperlink
- From: mayayana
- Re: Right click on text vs. right click on hyperlink
- References:
- Right click on text vs. right click on hyperlink
- From: Larry
- Re: Right click on text vs. right click on hyperlink
- From: mayayana
- Re: Right click on text vs. right click on hyperlink
- From: Larry
- Re: Right click on text vs. right click on hyperlink
- From: Larry
- Re: Right click on text vs. right click on hyperlink
- From: mayayana
- Right click on text vs. right click on hyperlink
- Prev by Date: Re: Adding method to response object
- Next by Date: Date confusion
- Previous by thread: Re: Right click on text vs. right click on hyperlink
- Next by thread: Re: Right click on text vs. right click on hyperlink
- Index(es):
Loading