using popupmenu, and passing the target frame's ID when clicked.Can I do this?

J

J

Hi,

I'm using the following code snippet to show popup menus (in a header
frame) and target the menu options to another frame. This works fine for
a single hard-coded frame (e.g. "2" below, in doClick) but I need to
pass in the target frame ID when the user clicks, the reason being that
different options will target different frames depending on who the user is.

the target frame name is in the target attribute of the link tag, i.e.
<a href="" target="here"> that the user clicks on but I don't know how
to make use of this in the code below.

Hope that makes sense, can anyone help?

J


function showMenu(linkObj, menuID)
{
var popupObj = window.createPopup();
var popupBodyObj = popupObj.document.body;
popupBodyObj.style.border = "0px black solid";
popupBodyObj.style.color="99ccff";
popupBodyObj.style.hover="red";
popupBodyObj.innerHTML = menuID.outerHTML;
for (var i = 0; i < popupBodyObj.all.length; i++)
{
if (popupBodyObj.all.tagName == "A")
popupBodyObj.all.onclick = doClick;
}
popupObj.show(0, linkObj.offsetHeight+2, menuID.offsetWidth,
menuID.offsetHeight, linkObj);

}


function doClick()
{
parent.frames(2).location = this.href;
return false;
}
 
R

Richard Cornford

J wrote:
function doClick()
{
parent.frames(2).location = this.href;
return false;
}

In any context where - this.href - can be used to reference the HREF of
a link - this.target - can be used to reference its TARGET attribute's
value.

(Incidentally, code posted to newsgroups should be formally block
indented, preferably with 2-4 space characters, if you want people to
read the code. The FAQ covers the details.)

Richard.
 
R

Randy Webb

Richard said:
J wrote:



In any context where - this.href - can be used to reference the HREF of
a link - this.target - can be used to reference its TARGET attribute's
value.

But "this.href" in that function doesn't refer to the links href
property, it is attempting to refer to the functions href property.
 
R

Richard Cornford

Randy Webb wrote:
But "this.href" in that function doesn't refer to the
links href property, it is attempting to refer to the
functions href property.

You don't expect me to actually read code that has not been presented in
a properly indented form to the extent of understanding what - this -
may refer to in any context, do you? ;)

Richard.
 
R

Randy Webb

Richard said:
Randy Webb wrote:



You don't expect me to actually read code that has not been presented in
a properly indented form to the extent of understanding what - this -
may refer to in any context, do you? ;)

You have a point ;)
 
F

Fred Oz

J wrote:
[...]
popupBodyObj.innerHTML = menuID.outerHTML;
for (var i = 0; i < popupBodyObj.all.length; i++)
{
if (popupBodyObj.all.tagName == "A")
popupBodyObj.all.onclick = doClick;
}


This snippet (and likely others) makes your code IE only. Is
that your intention? If not, other methods can be used that
allow non-IE browsers to use your page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top