Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When right click show my context menu according r-clicked href value

Status
Not open for further replies.

dimsis

Programmer
Aug 6, 2000
76
GR
I need a js context menu that popup's when the user right clicks on a dynamic option.
For example i have the following options:

1) Option 1 (which has a link: page1.asp?id=1)
2) Option 2 (which has a link: page1.asp?id=2)
3) Option 3 (which has a link: page1.asp?id=3)

When the user right clicks for example on option 2, i want to display the context menu and act or even show text in the menu, according the ID value....
So i need to know the value of the link of the right clicked href. Is it possible?

Thanx in advance,
Dimitris
 
And/or - they have some right-click menus there, too.

If you only need an IE-specific solution, you could delve into the murky world of X-Scriptlets (.sct files), and deliver your content using an OBJECT tag. This gives you access to a right-click context menu, scrolling, and other bits.

Dan
 
I know how to display a layered context menu with the right click, i have found a lot good examples.
What i can not find is how to determine the value of the link the user right clicked on...
 
Any popup window under or beside the right clicked option is good. I don't have any special wishes for this. (a layer with a table and the option could do the job just fine)
If you really need the code, you can use this:
<STYLE>
#contextMenu {
position: absolute;
visibility: hidden;
width: 120px;
background-color: lightgrey;
layer-background-color: lightgrey;
border: 2px outset white;
}

.A:Menu {
color: black;
text-decoration: none;
cursor: default;
width: 100%
}

.A:MenuOn {
color: white;
text-decoration: none;
background-color: darkblue;
cursor: default;
width: 100%
}
</STYLE>

<SCRIPT>
var menu;
function showMenu (evt) {
if (document.all) {
document.all.contextMenu.style.pixelLeft = event.clientX;
document.all.contextMenu.style.pixelTop = event.clientY;
document.all.contextMenu.style.visibility = 'visible';
return false;
}
else if (document.layers) {
if (evt.which == 3) {
document.contextMenu.left = evt.x;
document.contextMenu.top = evt.y;
document.contextMenu.onmouseout =
function (evt) { this.visibility = 'hide'; };
document.contextMenu.visibility = 'show';
return false;
}
}
return true;
}
if (document.all)
document.oncontextmenu =showMenu;
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown = showMenu;
}
</SCRIPT>

<DIV ID=&quot;contextMenu&quot;
ONMOUSEOUT=&quot;menu = this; this.tid = setTimeout
('menu.style.visibility = \'hidden\'', 20);&quot;
ONMOUSEOVER=&quot;clearTimeout(this.tid);&quot;
>
<A HREF=&quot;#&quot;;
CLASS=&quot;menu&quot;
ONMOUSEOVER=&quot;this.className = 'menuOn'&quot;
ONMOUSEOUT=&quot;this.className = 'menu';&quot;
>
Link 1
</A>
<BR>
<A HREF=&quot;#&quot;; CLASS=&quot;menu&quot;
ONMOUSEOVER=&quot;this.className = 'menuOn'&quot;
ONMOUSEOUT=&quot;this.className = 'menu';&quot;
>
Link 2
</A>
</DIV>

or any of these links code:
Thanx in advance,
Dimitris
 
If it helps,
this cms does what i need to do.

Just enter the demo with:
Username: admin
Password: admin

Click the SITE tab.
Right click over any option of the tree menu in the left.

This is excactly what i want to do...
 
How many browsers should this work with?

event.srcElement.href is probably the answer to one of your questions.



----------
I'm willing to trade custom scripts for... [see profile]
 
Re to stormbind.
Internet Explorer 5.5 or > versions....
Any example please?
 
with other browsers you need to specify the event when firing. Not sure whether you need to specify srcElement or not so that may need editing.



<img onclick=&quot;getData('value',event,this)&quot; id=&quot;myElement&quot;>

function getData(value,event,srcElement){
alert(event.srcElement.id);
}

----------
I'm willing to trade custom scripts for... [see profile]
 
Ugh, what am I thinking? Where is the edit button.. doh!

If you specify the object (this) then you don't need the event.

alert(object.id);

However, passing the event is still needed for use with some methods.

----------
I'm willing to trade custom scripts for... [see profile]
 
I don't think i get it...
I have

<cfoutput query=&quot;menu&quot;>
<a href=&quot;page.cfm?ID=#id#&quot;>#title#</a>
</cfoutput>

the above returns something like that in HTML (user result):
<a href=&quot;page.cfm?ID=5&quot;>title 5</a>
<a href=&quot;page.cfm?ID=7&quot;>title 7</a>
<a href=&quot;page.cfm?ID=9&quot;>title 9</a>
What i need is when the user right clicks OVER one of the titles, for example if the user RIGHT click the &quot;title 7&quot; option, to show a popup (layerer or else) window with options like:
Delete article Title 7
Edit article Title 7
Move article Title 7 down
Move article Title 7 up

etc...
This means that the popup window values and actions are related with the right clicked option...

Any examples of how to do this?
Thanx in advance.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top