By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,054 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

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

P: n/a
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[i].tagName == "A")
popupBodyObj.all[i].onclick = doClick;
}
popupObj.show(0, linkObj.offsetHeight+2, menuID.offsetWidth,
menuID.offsetHeight, linkObj);

}
function doClick()
{
parent.frames(2).location = this.href;
return false;
}
Jul 23 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
J wrote:
<snip>
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.
Jul 23 '05 #2

P: n/a
Richard Cornford wrote:
J wrote:
<snip>
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.


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

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #3

P: n/a
Randy Webb wrote:
<snip>
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.
Jul 23 '05 #4

P: n/a
Richard Cornford wrote:
Randy Webb wrote:
<snip>
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? ;)


You have a point ;)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #5

P: n/a
J wrote:
[...]
popupBodyObj.innerHTML = menuID.outerHTML;
for (var i = 0; i < popupBodyObj.all.length; i++)
{
if (popupBodyObj.all[i].tagName == "A")
popupBodyObj.all[i].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.

--
Fred
Jul 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.