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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Navigating out of frameset 1

Status
Not open for further replies.

pookie62

Technical User
Oct 22, 2004
139
GB
Hi,
I have a frameset, main and leftframe.
In the mainframe I have a menu poping up when mouse is rightclicked. When I want to to mainpage its loaded in the mainframe.
How do I prevent that and load the normal page (no frameset)
and closing the frameset ?
Thanks
 
Your post is so garbled it makes no sense. Do you just want links to be loaded outside of the frameset? If so, give them a target of "_top":

Code:
<a href="[URL unfurl="true"]http://www.google.co.uk/"[/URL] target="_top">some link</a>

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Hi Dan,
Sorry for not being clear..
The rightclick menu (js file) is build like this:
Code:
m1[8]=new Array("Jouw account","../menu/icons/pelle.gif","goto '../Login/main.php')");
m1[9]=new Array("blablapage","../menu/icons/pelle.gif","goto '../Login/blabla.php')");
Point is that from all 'normal' pages this menu works fine except for a page which is build from two frames: left and main.
The rightclick menu is visible (in mainframe) and working, but when I click a menuitem i.e mainpage (item 8) the page is loaded in the mainframe.
I want it to load normally as single page in a normal full browser screen.
Hope it makes more sense now..
Thanks for your time and help ! Appreciate..

 
You'll need to give all the details about the menu you are using, including how the clicks function, whether it uses standard anchor elements, etc. Better still, post a URL to your page.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
URL is not possible, sorry...
This is the menuscript itself:
Code:
// Menu script created by Kari Hollo, Finland
// Use these files "as is". You may modify them freely.
// If you can't get them work after modificatins, I don't care...
// Wrote and tested with MS IE6 only...
// Modified by JavaScript Kit ([URL unfurl="true"]http://www.javascriptkit.com)[/URL]
// constants ********

//default/required menu images:
var myi=new Image; myi.src="../menu/icons/arrow__r.gif";		//submenu arrow
var myiw=new Image; myiw.src="..menu/icons/arrow__rw.gif";		//same as white
var myie=new Image; myie.src="../menu/icons/arrow__e.gif";		//empty pic
var myis=new Image; myis.src="../menu/icons/spacer.gif";		//spacer
var myisb=new Image; myisb.src="../menu/icons/spacer__b.gif";	//enpty end pic left to spacer


var kto=2000;	//killTimeout [ms]
var mymenuwidth="150px"     //menu width				
var bg_color="#D6D6D6";	    //colors...
var bg_color_hl="navy";	    //syncronize with css file!!
var fg_color="black";
var fg_color_hl="white";
var spc="#SPACER#";	//spaser sign
var arr="#ARROW#";	//submenu sign


// caption/spacer,icon,gimmick/submenu
// MAIN MENU, DO NOT REMOVE, EDIT ONLY *********	
var m1=new Array;
m1[0]=new Array("");
m1[1]=new Array("Home","../menu/icons/ico_gun01.gif","goto('[URL unfurl="true"]http://www.notyetimplemted.nl')");[/URL]
m1[2]=new Array(spc); //add divider
m1[3]=new Array("Nieuws","../menu/icons/pelle.gif","goto('../info/nieuws.php target="_top')");
m1[4]=new Array("Info"+arr,"../menu/icons/pelle.gif",11); //denote sub menu (using "arr")
m1[5]=new Array("Links","../menu/icons/pelle.gif","goto('../info/clublinks.php')");
m1[6]=new Array("Wedstrijd-info"+arr,"../menu/icons/pelle.gif",12);
m1[7]=new Array("Competitie"+arr,"../menu/icons/pelle.gif",13);
m1[8]=new Array("Agenda"+arr,"../menu/icons/pelle.gif",21);
m1[9]=new Array("Jouw account","../menu/icons/pelle.gif","goto('../Loginsys/main.php')");

// name submenus reasonable!
// m1## 1.level, m2## 2.level and so on...

// 1ST SUB MENU
var m11=new Array;	
m11[0]=new Array("");
m11[1]=new Array("ASN Forum","../menu/icons/pelle.gif","goto('[URL unfurl="true"]http://www.notyetimplemented.nl/phpbb2/')");[/URL]
m11[2]=new Array("ASN Folder","../menu/icons/pelle.gif","goto('../info/folder.php')");
m11[3]=new Array("Regelement","../menu/icons/pelle.gif","goto('../info/reglem.php')");
m11[4]=new Array("Handl. Baancomm","../menu/icons/pelle.gif","goto('../info/hl-bc.php')");
m11[5]=new Array("Het Bestuur","../menu/icons/pelle.gif","goto('../info/bestuur.php')");
m11[6]=new Array("Feedback","../menu/icons/pelle.gif","goto('../Forms/feedback.php')");
m11[7]=new Array("Inschrijven","../menu/icons/pelle.gif","goto('../Forms/ASNForm.php')");

// 2ND SUB MENU
var m12=new Array;	
m12[0]=new Array("");
m12[1]=new Array("Uitslagen 2006","../menu/icons/pelle.gif","goto('../wedstrijd/w_uitslag.php')");
m12[2]=new Array("Uitslagen 2005","../menu/icons/pelle.gif","goto('../wedstrijd/w_uitslag05.php')");
m12[3]=new Array("Wedstrijd opgeven","../menu/icons/pelle.gif","goto('../Forms/WedstrijdForm.php')");
m12[4]=new Array("ASN Score","../menu/icons/pelle.gif","goto('../files/asnscore/login.php')");

// 3ND SUB MENU
var m13=new Array;	
m13[0]=new Array("");
m13[1]=new Array("Info","../menu/icons/pelle.gif","goto('../comp/compinfo.php')");
m13[2]=new Array("Competitiestanden","../menu/icons/pelle.gif","goto('../comp/compmenu06_index.php')");
m13[3]=new Array("Competitie 2005","../menu/icons/pelle.gif","goto('../comp/compmenu05_index.php')");


// 1ST SUB SUB MENU
var m21=new Array;
m21[0]=new Array("");
m21[1]=new Array("Januari","../menu/icons/pelle.gif","goto('../agenda/agenda.php#januari')");
m21[2]=new Array("Februari","../menu/icons/pelle.gif","goto('../agenda/agenda.php#februari')");
m21[3]=new Array("Maart","../menu/icons/pelle.gif","goto('../agenda/agenda.php#maart')");
m21[4]=new Array("April","../menu/icons/pelle.gif","goto('../agenda/agenda.php#april')");
m21[5]=new Array("Mei","../menu/icons/pelle.gif","goto('../agenda/agenda.php#mei')");
m21[6]=new Array("Juni","../menu/icons/pelle.gif","goto('../agenda/agenda.php#juni')");
m21[7]=new Array("Juli","../menu/icons/pelle.gif","goto('../agenda/agenda.php#juli')");
m21[8]=new Array("Augustus","../menu/icons/pelle.gif","goto('../agenda/agenda.php#augustus')");
m21[9]=new Array("September","../menu/icons/pelle.gif","goto('../agenda/agenda.php#september')");
m21[10]=new Array("Oktober","../menu/icons/pelle.gif","goto('../agenda/agenda.php#oktober')");
m21[11]=new Array("November","../menu/icons/pelle.gif","goto('../agenda/agenda.php#november')");
m21[12]=new Array("December","../menu/icons/pelle.gif","goto('../agenda/agenda.php#december')");


//ENTER MENU IDs of above. UPDATE IF ADD/REMOVE MENUS!
var mvect=new Array(1,11,12,13,21);			


// END OF EDITTING. variables ********
var th;							//menu height
var tw;							//menu width
var vas=0;						//on left flag
var llv=false;						//menu visible flag
var tid;						//timeout id
var ksm=0;						//known sub sub menu id


//************** FUNCTIONS
//******** base function to create menus

// error handler ***************
function stoperror(){
	return true;
}
window.onerror=stoperror;  //suppress potential JS errors. Comment line if you need to debug page.

function createMenus(){
	for(xyzzy=0;xyzzy<mvect.length;xyzzy++){
		document.write("<DIV id='teva"+mvect[xyzzy]+"' class='men'>");
		document.write("<TABLE WIDTH='100%' BORDER=0 CELLSPACING=0 CELLPADDING=0>");
		initMenu(mvect[xyzzy]);
		document.write("</TABLE></DIV>");
	}
}

//******** initialization
function initMenu(t){
var obj=eval("teva"+t);	//container
var vect=eval("m"+t);	//menu
var ve1;				//caption
var ve2;				//picture
var ve3;				//trick/no of submenu 
var spacers=0;			//spacer counter
	obj.style.height=(vect.length-1)*16+"px";
	obj.style.width=mymenuwidth;
	if(t==1){
		th=obj.style.height.substr(0,obj.style.height.length-2);
		tw=obj.style.width.substr(0,obj.style.width.length-2);
	}
	for(i=1;i<vect.length;i++){
		ve1=eval("vect["+i+"][0]");
		document.write("<TR>");
		if(ve1==spc){
			spacers++;
			document.write("<TD colspan=3 style='height:8px;'>"+
				"<img src='"+myisb.src+"' style='width:3px;height:2px;'>"+
				"<img src='"+myis.src+"' style='width:95%;height:2px;'></TD>");
		}else{ 
			ve2=eval("vect["+i+"][1]");
			ve3=eval("vect["+i+"][2]");
			if(ve1.match(arr)){
				var oy=16*(i-1)-spacers*8;
				document.write("<TD class='imgtd' style='border:1px solid "+bg_color+";' "+
					"id='m_"+t+"_"+i+"a' onmouseover='act_td("+t+","+i+");showSubMenu("+t+","+ve3+","+oy+");' "+
					"onmouseout='nonact_td("+t+","+i+");'>"+
					"<img id='m_"+t+"_"+i+"ap' src='"+ve2+"' class='icondimensions'></TD>");
				document.write("<TD onmouseover='act_td("+t+","+i+");showSubMenu("+t+","+ve3+","+oy+");' "+
					"onmouseout='nonact_td("+t+","+i+");' class='tdmenu' "+
					"id='m_"+t+"_"+i+"'>&nbsp;"+ve1.substr(0,ve1.length-7)+"</TD>");
				document.write("<td class='imgtd' id='m_"+t+"_"+i+"b' "+
					"onmouseover='act_td("+t+","+i+");showSubMenu("+t+","+ve3+","+oy+");' "+
					"onmouseout='nonact_td("+t+","+i+");'>"+
					"<img class='arr' id='m_"+t+"_"+i+"bp' src='"+myi.src+"'></td>");
			}else{
				document.write("<TD class='imgtd' style='border:1px solid "+bg_color+";' "+
					"id='m_"+t+"_"+i+"a' onmouseover='act_td("+t+","+i+");' "+
					"onmouseout='nonact_td("+t+","+i+");' "+
					"onclick='eval(m"+t+"["+i+"][2]);'>"+
					"<img id='m_"+t+"_"+i+"ap' src='"+ve2+"' class='icondimensions'></TD>");
				document.write("<TD onmouseover='act_td("+t+","+i+");'	"+
					"onmouseout='nonact_td("+t+","+i+");' onclick='eval(m"+t+"["+i+"][2]);' "+
					"class='tdmenu' id='m_"+t+"_"+i+"'>&nbsp;"+ve1+"</TD>");
				document.write(	"<td class='imgtd' id='m_"+t+"_"+i+"b' "+
					"onmouseover='act_td("+t+","+i+");' "+
					"onmouseout='nonact_td("+t+","+i+");' "+
					"onclick='eval(m"+t+"["+i+"][2]);'>"+
					"<img class='emp' id='m_"+t+"_"+i+"bp' src='' width='12px' height='12px'></td>");
			}
		}
		document.write("</TR>");
	}
	if(t==1){
		obj.style.height=(vect.length-1)*16-spacers*8+"px";
		th=obj.style.height.substr(0,obj.style.height.length-2);
	}
}
// on hover **********
function act_td(t,i){



	window.clearTimeout(tid);
var obj=eval("m_"+t+"_"+i);
	if(t==1) 
		hideSubMenu();
	else
		hideKnownSubMenu(t);
	obj.style.backgroundColor=bg_color_hl;
	obj.style.color=fg_color_hl;
	act1_td(eval(obj.id+"a")); //send cell id

	act2_td(eval(obj.id+"b"));
}
// on mouse out *********
function nonact_td(t,i){
var obj=eval("m_"+t+"_"+i);
	obj.style.backgroundColor=bg_color;
	obj.style.color=fg_color;
	nonact1_td(eval(obj.id+"a"));
	nonact2_td(eval(obj.id+"b"));
	tid=setTimeout('showMenu("mousedown")',kto);
}
//******** left=icon cell hover...
function act1_td(t){
var cel=eval(t);
var pix=eval(t.id+"p");
	if(pix.src!=myie.src)
		cel.style.border='1px outset';
	else{
		cel.style.border="1px solid "+bg_color_hl;
		cel.style.backgroundColor=bg_color_hl;
	}
}
// icon cell on mouse out *********
function nonact1_td(t){
var cel=eval(t);
var pix=eval(t.id+"p");
	if(pix.src!=myie.src)
		cel.style.border="1px solid "+bg_color;
	else{
		cel.style.border="1px solid "+bg_color;
		cel.style.backgroundColor=bg_color;
	}
}
//******** right cell for submenu arrow on hover
function act2_td(t){
var cel=eval(t);
var pix=eval(t.id+"p");
	cel.style.backgroundColor=bg_color_hl;
	if(cel.className!="emp") pix.src=myiw.src;
}
//********** same onmouseout........
function nonact2_td(t){
var cel=eval(t);
var pix=eval(t.id+"p");
	cel.style.backgroundColor=bg_color;
	cel.style.color=fg_color;
	if(cel.className!="emp") pix.src=myi.src;
}
// needs explanations?
function showMenu(e){
	if(llv==true)
		hideMenu();
	else{
		clearTimeout(tid);
		var ah=document.body.clientHeight-th;
		var aw=document.body.clientWidth-tw;

		if(e.clientY < ah) teva1.style.top=e.clientY;
		else teva1.style.top=e.clientY-th;

		if(e.clientX < aw) {teva1.style.left=e.clientX;vas=0;}
		else {teva1.style.left=e.clientX-tw;vas=1;}
		
		teva1.style.visibility='visible';
		llv=true;
		tid=window.setTimeout("hideMenu()",kto);
	}
}
// ...........
function showSubMenu(c,t,y){
		clearTimeout(tid);
var tobj=eval("teva"+c);
var obj=eval("teva"+t);
var ox=tobj.style.left.substr(0,tobj.style.left.length-2); 
var oy=tobj.style.top.substr(0,tobj.style.top.length-2); 
var oh=obj.style.height.substr(0,obj.style.height.length-2);
var ow=obj.style.width.substr(0,obj.style.width.length-2);
	if(vas==0){
		if(Math.round(ox) > Math.round(document.body.clientWidth)-Math.round(ow)*2-10)
			obj.style.left=Math.round(ox)-Math.round(ow)+2;
		else
			obj.style.left=Math.round(ox)+Math.round(ow)-5;
	}else
		obj.style.left=Math.round(ox)-Math.round(ow)+2;
	if(Math.round(oy)+Math.round(y) < Math.round(document.body.clientHeight)-Math.round(oh))
		obj.style.top=Math.round(oy)+Math.round(y);
	else
		obj.style.top=Math.round(oy)+Math.round(y)-Math.round(oh);
	obj.style.visibility='visible';
	ksm=t;
}
//...............
function hideMenu(){
	clearTimeout(tid);
	teva1.style.visibility='hidden';
	hideSubMenu();
	llv=false;
}
//.................
function hideSubMenu(){
var obj;
	for(j=1;j<mvect.length;j++){
		obj=eval("teva"+mvect[j]);
		obj.style.visibility='hidden';
	}
}
//.................
function hideKnownSubMenu(t){
	if(ksm>0 && ksm!=t){
var obj;
		for(j=1;j<mvect.length;j++){
			if(mvect[j]>t){
				obj=eval("teva"+mvect[j]);
				obj.style.visibility='hidden';
			}
		}
		ksm=0;
	}
}

function goto(url){
window.location=url
}

//...............

And it's called like this on the pages:
HEAD section:
Code:
<LINK HREF="../menu/mymenu.css" type="text/css" REL="stylesheet">
<SCRIPT tyle="text/javascript">
var iecheck=document.all&&document.getElementById
if (iecheck){
document.write('<script type="text/javascript" src="../menu/mymenu.js"><\/script>')
}
</SCRIPT>

BODY section:
Code:
<body>

<SCRIPT LANGUAGE="javascript">
if (iecheck){
createMenus();
document.oncontextmenu=function(){
showMenu(event);
return false;
}
document.onmouseup=function(){
hideMenu(event);
return false;
}
}
</SCRIPT>

</body></html>
 
Add a new function to the menu code:

Code:
function gotoNoFrames(url){
  top.location = url;
}

and then for any menu item you want to load in the top-level browser window, not frame, modify the "goto(" call in the menu item to "gotoNoFrames(".

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Oke thanks a lot Dan !
Going to try it out..
 
:-( Unfortunately it doesn't help..
Makes no difference, When I am in the mainframe page and click a menuitem (I changed all 'goto' to 'gotoNoFrames')
still loads IN the mainframe.
Added the new function just like you said..
In the mymenu.js :
Code:
//************** FUNCTIONS
function gotoNoFrames(url){
  top.location = url;
}
// error handler ***************

Links are now like this:
Code:
m21[11]=new Array("November","../menu/icons/pelle.gif","gotoNoFrames('../agenda/agenda.php#november')");
m21[12]=new Array("December","../menu/icons/pelle.gif","gotoNoFrames('../agenda/agenda.php#december')");

Thanks again for your time..!
 
That's odd. Can you put an alert in the function just to see what is presently loaded into the top-level page:

Code:
function gotoNoFrames(url){
  alert(top.location);
  top.location = url;
}

is it the name of your frameset page?

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I added the alert, but nowhere an alert in the pages.. (have tried several pages)
looks like this function is not performed anywhere..
 
Maybe you're using old or cached code? Or even code from a different folder?

Anyway - once you get the alert, I'm betting the code will work, so try clearing your cache, rebooting, standing on one leg while saying "wibble wibble", etc ;-)

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
You're great ! I'm awake finally.. ;-)
The original function:
function goto(url){
window.location=url
}
was below you're
function gotoNoFrames(url){
top.location = url;
}

Thanks a million Dan !! gave you a star, you deserved it !

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top