[Javascript] Newbie dipping toes in water

Peter Vogel pvogel at righthemisphere.com.au
Mon Mar 3 16:10:08 CST 2003


Your script does work when placed in an html document.

Perhaps the problem is this: I'm not putting the script in
an html page, I am running the script from a local file and
calling it via an extra entry in the right-click context
menu of IE.  I have added the menu entry using the registry
editor, and when I select the new option from the
right-click menu it correctly executes the script.

The problem is I can't find out how to pass the script the
link that was clicked on.

Thanks again

Peter

On Mon, 03 Mar 2003 22:55:44 +0100
"BEKIM BACAJ" <trojani2000 at hotmail.com> wrote:

> 
> Sorry, the comment line might have break in two lines and caused the error. 
> I've tested the script and the cript does display an alertBox with the HREF 
> addres. I will give it once again without comments. Copy and paste it into 
> an any html text document that contains Ancors and right-clik on them. I'm 
> convinced that you will get that links text previewed into the alertBox.
> 
> After you get it to work, we can talk about the implementation, into you'r 
> script, but first, I too must se the handler you're using. For getting it to 
> be displayed in the menu. You can also try alert(itsAncor.href) and get the 
> same result.
> If once again this does not display the alert box with ancors path in it, 
> the best way to solve this, is for you sending us the base script you're 
> using and see what the problem is,-might also be the case that you've used 
> this local variable 'itsAncor' in global manner. The value of itsAncor lives 
> and dies while exec of the getHREF function only. You must include the 
> commands of the menu inside this function, or make this value available in 
> some other global var like in this modified script:
> <script>
> var theLocation=""
> 
> function getHREF(){
> 
> var	itsAncor=window.event.srcElement
> 
> 	if ( itsAncor.tagName == "A" ) {
>             theLocation=itsAncor
> 		alert(theLocation)
> return(false)
> 	}
> }
> document.oncontextmenu=getHREF
> </script>
> 
> P.S.
> 
> -Copy only the text inside the <script></script> tags and put it inside 
> you'r existing script Tags of the document.
> 
> Regards!
> 
> 
> 
> 
> 
> >From: Peter Vogel <pvogel at righthemisphere.com.au>
> >Reply-To: javascript at LaTech.edu
> >To: javascript at LaTech.edu
> >Subject: Re: [Javascript] Newbie dipping toes in water
> >Date: Mon, 03 Mar 2003 15:10:15 +1100
> >
> >Thanks for the example. Unfiortunately I couldn't get it to work, and
> >there were aspects I didn't understand, so I thought I should try
> >cutting it down to this:
> >
> ><HTML>
> ><SCRIPT LANGUAGE="JavaScript">
> >var	itsAncor=window.event.srcElement
> >	if ( itsAncor.tagName == "A" ); { alert(itsAncor)}
> ></SCRIPT>
> ></HTML>
> >
> >Now i get an error saying "Object required" in line 3.
> >
> >Could you tell me where I can find details/explanations of the objects
> >e.g.
> >window.event.srcElement
> >
> >Where is there a goiod general Javascript reference site?
> >
> >Thanks
> >
> >Peter
> >
> >On Sun, 02 Mar 2003 21:45:13 +0100
> >"BEKIM BACAJ" <trojani2000 at hotmail.com> wrote:
> >
> > > Hello there,
> > > here is some script I wrote, can help you getting ideas:
> > > <script>
> > > function getHREF(){
> > >
> > > var	itsAncor=window.event.srcElement
> > >
> > > 	if ( itsAncor.tagName == "A" ) {//making sure the command is triggered 
> >only
> > > wen ancor encountered
> > > 		alert(itsAncor)//display the ancor navigational address
> > > return(false)//dissabling the contextMenu over ancorTags
> > > 				}
> > > 		}
> > > document.oncontextmenu=getHREF//invoking the command
> > > </script>
> > >
> > > Any further questions, -no hasitations, the same forum!
> > >
> > > Cheers!
> > >
> > >
> > >
> > > >From: Peter Vogel <pvogel at righthemisphere.com.au>
> > > >Reply-To: javascript at LaTech.edu
> > > >To: javascript at LaTech.edu
> > > >Subject: [Javascript] Newbie dipping toes in water
> > > >Date: Sun, 02 Mar 2003 17:54:00 +1100
> > > >
> > > >I want to write a JavaScript that does something like the "copy 
> >shortcut"
> > > >command in the right-click menu in IE6.  That is, I want tto read the
> > > >value of the link that was right-clicked before selecting my script 
> >from
> > > >the right-click menu.
> > > >
> > > >I have managed to do the registry entires to add the item to the menu,
> > > >and it executes a file of my choice, however now I need to know where 
> >to
> > > >find the definitions I will need to use to get the link data from the
> > > >displayed html document into my script.
> > > >
> > > >I have found examples that use things like
> > > >
> > > >var win = external.menuArguments;
> > > >document.all.location.value = win.location.href;
> > > >document.all.location.select();
> > > >
> > > >but can't find where this is all defined/explained.
> > > >
> > > >Thanks for any advice on this.
> > > >
> > > >Peter
> > > >
> > > >
> > > >_______________________________________________
> > > >Javascript mailing list
> > > >Javascript at LaTech.edu
> > > >https://lists.LaTech.edu/mailman/listinfo/javascript
> > >
> > >
> > > _________________________________________________________________
> > > Help STOP SPAM with the new MSN 8 and get 2 months FREE*
> > > http://join.msn.com/?page=features/junkmail
> > >
> > > _______________________________________________
> > > Javascript mailing list
> > > Javascript at LaTech.edu
> > > https://lists.LaTech.edu/mailman/listinfo/javascript
> >
> >
> >_______________________________________________
> >Javascript mailing list
> >Javascript at LaTech.edu
> >https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 
> _________________________________________________________________
> Tired of spam? Get advanced junk mail protection with MSN 8. 
> http://join.msn.com/?page=features/junkmail
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript





More information about the Javascript mailing list