Click to See Complete Forum and Search --> : New Window Pop-up???
petrocan
06-09-2003, 08:56 AM
I was wondering (within the following coding) what prompt/script I need to insert to have this link pop-up a new window??? (like an 'onclick' type thing?)
<div Id="menu2" class="menu">
<div Id="menuItem2_1" class="menuItem" cmd="www.abc.com">ABC</div>
<div Id="menuItem2_2" class="menuItem" cmd="www.def.com">DEF</div>
Any help would be appreciated.
pc
petrocan
06-09-2003, 09:00 AM
I was wondering (within the following coding) what prompt/script I need to insert to have this link pop-up a new window??? (like an 'onclick' type thing?)
<div Id="menu2" class="menu">
<div Id="menuItem2_1" class="menuItem" cmd="www.abc.com">ABC</div>
<div Id="menuItem2_2" class="menuItem" cmd="www.def.com">DEF</div>
Any help would be appreciated. I'm using javascripting if that helps, and yes I have posted under the javascript board too.
pc
Moderators Note
Please do not cross post,its not considered nice and is an extra load on this forums resources.
Khalid Ali
06-09-2003, 09:18 AM
There is pretty much nothin you can do in the code snippet you posted above..
Look for the javascript code where you have something like this
window.open....
and change the above to this
window.location.href = "url"
petrocan
06-09-2003, 09:25 AM
The only problem I see is that I have multiple links within this cascading menu, so how do I assocaite the right links to the correct menu item...here is most of the coding (I've bolded the link, but there are others):
<html>
<head>
<title>Customer Service</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="CascadeMenu.css" rel="stylesheet">
<script language="javascript" src="CascadeMenu.js">
</script>
</head>
<body bgcolor="#f41417" text="#000000" OnLoad="InitMenu()" Onclick="HideMenu(menuBar)" ID="Bdy">
<table width="650" border="0">
<tr>
<td bgcolor="#f41417" align="center"><img src="images/csn_title.gif" width="650" height="90"></td>
</tr>
<tr>
<td bgcolor="#f41417">
<DIV Id="menuBar" class="menuBar" >
<DIV Id="Bar1" class="Bar" menu="menu1">AgentView</DIV>
<DIV Id="Bar2" class="Bar" menu="menu2">Phone List</DIV>
<DIV Id="Bar3" class="Bar" menu="menu3">Schedule</DIV>
<DIV Id="Bar4" class="Bar" menu="menu4">Petro-Points</DIV>
<DIV Id="Bar5" class="Bar" menu="menu8">SuperPass</DIV>
<DIV Id="Bar6" class="Bar" menu="menu9">Mobila</DIV>
</DIV>
<!--MenuItem Definition -->
<div Id="menu1" class="menu">
<div Id="menuItem1_1" class="menuItem" cmd="index.htm">Open</div>
</div>
<div Id="menu2" class="menu">
<div Id="menuItem2_1" class="menuItem" menu="menu10" cmd="PDF/PhoneListing.pdf">CSN</div>
<div Id="menuItem2_2" class="menuItem" menu="menu11">RSC</div>
<div Id="menuItem2_3" class="menuItem" menu="menu12">Points</div>
<div Id="menuItem2_4" class="menuItem" menu="menu13">2nd Tier</div>
<div Id="menuItem2_5" class="menuItem" menu="menu14">Sales & Accounting</div>
</div>
Khalid Ali
06-09-2003, 09:30 AM
Originally posted by Khalid Ali
There is pretty much nothin you can do in the code snippet you posted above..
Look for the javascript code where you have something like this
window.open....
and change the above to this
window.location.href = "url"
I wonder you read my post above...because your solution by staying with in the same coding structure, is in the javascript part of the code no in html section.
petrocan
06-09-2003, 09:35 AM
Sorry Khalid...I honestly know nothing about javascript...here is the js code...where would I put the new.window stuff???
function InitMenu()
{
var bar = menuBar.children
for(var i=0;i < bar.length;i++)
{
var menu=eval(bar[i].menu)
menu.style.visibility = "hidden"
bar[i].onmouseover = new Function("ShowMenu("+bar[i].id+")")
var Items = menu.children
for(var j=0; j<Items.length; j++)
{
var menuItem = eval(Items[j].id)
if(menuItem.menu != null)
{
menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
//var tmp = eval(menuItem.id+"_Arrow")
// tmp.style.pixelLeft = menu.getBoundingClientRect().Right //- tmp.offsetWidth - 15
FindSubMenu(menuItem.menu)}
if(menuItem.cmd != null)
{
menuItem.onclick = new Function("Do("+menuItem.id+")") }
menuItem.onmouseover = new Function("highlight("+Items[j].id+")")
}
}
}
function FindSubMenu(subMenu)
{
var menu=eval(subMenu)
var Items = menu.children
for(var j=0; j<Items.length; j++)
{
menu.style.visibility = "hidden"
var menuItem = eval(Items[j].id)
if(menuItem.menu!= null)
{
menuItem.innerHTML += "<Span Id="+menuItem.id+"_Arrow class='Arrow'>4</Span>"
// var tmp = eval(menuItem.id+"_Arrow")
//tmp.style.pixelLeft = 35 //menuItem.getBoundingClientRect().right - tmp.offsetWidth - 15
FindSubMenu(menuItem.menu)
}
if(menuItem.cmd != null)
{
menuItem.onclick = new Function("Do("+menuItem.id+")") }
menuItem.onmouseover = new Function("highlight("+Items[j].id+")")
}
}
function ShowMenu(obj)
{
HideMenu(menuBar)
var menu = eval(obj.menu)
var bar = eval(obj.id)
bar.className="barOver"
menu.style.visibility = "visible"
menu.style.pixelTop = obj.getBoundingClientRect().top + obj.offsetHeight + Bdy.scrollTop
menu.style.pixelLeft = obj.getBoundingClientRect().left + Bdy.scrollLeft
}
function highlight(obj)
{
var PElement = eval(obj.parentElement.id)
if(PElement.hasChildNodes() == true)
{ var Elements = PElement.children
for(var i=0;i<Elements.length;i++)
{
TE = eval(Elements[i].id)
TE.className = "menuItem"
}
}
obj.className="ItemMouseOver"
window.defaultStatus = obj.title
ShowSubMenu(obj)
}
function Do(obj)
{
var cmd = eval(obj).cmd
window.navigate(cmd)
}
function HideMenu(obj)
{
if(obj.hasChildNodes()==true)
{
var child = obj.children
for(var j =0;j<child.length;j++)
{
if (child[j].className=="barOver")
{var bar = eval(child[j].id)
bar.className="Bar"}
if(child[j].menu != null)
{
var childMenu = eval(child[j].menu)
if(childMenu.hasChildNodes()==true)
HideMenu(childMenu)
childMenu.style.visibility = "hidden"
}
}
}
}
function ShowSubMenu(obj)
{
PMenu = eval(obj.parentElement.id)
HideMenu(PMenu)
if(obj.menu != null)
{
var menu = eval(obj.menu)
menu.style.visibility = "visible"
menu.style.pixelTop = obj.getBoundingClientRect().top + Bdy.scrollTop
menu.style.pixelLeft = obj.getBoundingClientRect().right + Bdy.scrollLeft
if(menu.getBoundingClientRect().right > window.screen.availWidth )
menu.style.pixelLeft = obj.getBoundingClientRect().left - menu.offsetWidth
}
}
Khalid Ali
06-09-2003, 10:09 AM
Search for this part of the code in your javascript
function Do(obj)
{
var cmd = eval(obj).cmd
window.navigate(cmd)
}
and replace it with this
function Do(obj)
{
var cmd = eval(obj).cmd
//window.navigate(cmd)
window.location.href = cmd;
}
petrocan
06-09-2003, 10:21 AM
Ok I understand now...but...I know the //means I've turned something into a comment and does nothing to the code as far as function goes, but with the new part...
window.location.href = cmd;
...it makes the link work, but opens in the same window? Anything else you can think of, I really appreciate this.
function Do(obj) {
var cmd = eval(obj).cmd;
window.open(cmd);
}
Khalid Ali
06-09-2003, 10:37 AM
lol..I actually lost that you wanted to open a new window..:-)
yep as pyro suggested above
the function should be like this
function Do(obj)
{
var cmd = eval(obj).cmd
//window.navigate(cmd)
window.open(cmd,"nwin","")
//in the 3 part of the param where qoutes are empty, you can suggest window properties.
}
petrocan
06-09-2003, 11:26 AM
It works...thanks to the both of you. Again I really appreciate it.
Khalid Ali
06-09-2003, 11:33 AM
You are welcome..:p