Link to home
Start Free TrialLog in
Avatar of eaweb
eawebFlag for undefined

asked on

iframe requesting a query string

hi,

i have this main asp with a link to page A. page A consist of 2 iframes. iframe 1 (top) has 3 links. iframe2 is xml with its xsl. when click on the link in main asp to page A it send a variable wich i want to get back in the stylesheet for example like:

onload="flag=true" onunload="if (flag) top.window.location='naverror.atm?check=<%= Request.Querystring("eq") %>'"

and when clicking one of the link i iframe 1 i need to pass a flag to iframe2 like:
onclick="flag = false" so it doesn't go to the naverror page.

because right now i have this problem that when clicking one of the links in iframe 1 i set the flag to false with onclick and another page has to display in iframe 2 but it doesn't seem to get the flag set to flase so it can display the new page instead of the naverror page. the naverror page is suppose to work when hitting the back button. not when clicking a link in iframe1.

i hope i was clear enough on my problem
Avatar of effx
effx
Flag of United Kingdom of Great Britain and Northern Ireland image

Have you tried AJAX instead of iframes ? http://www.w3schools.com/ajax/default.asp
Avatar of eaweb

ASKER

what i want to do is:

when click on a link  i need to pass a "false" flag value to the iframe.
the flag for onunload in the iframe needs to become false.

onload="flag=true" onunload="if (flag) top.window.location='naverror.atm?check=<%= Request.Querystring("eq") %>'"
Avatar of eaweb

ASKER

the

onload="flag=true" onunload="if (flag) top.window.location='naverror.atm?check=<%= Request.Querystring("eq") %>'"

is in the body of an xsl in the iframe
Avatar of eaweb

ASKER

this is my page structure:

link 1 link 2 link 3

<iframeA>

in iframeA i display an xml file with its xsl
the xsl has in its body tag the follwing:

onload="flag=true" onunload="if (flag) top.window.location='naverror.atm?check=<%= Request.Querystring("eq") %>'"

i need to get the query string "eq" sent by the links 123 and on each link click i send flag is false.

<a href="linktest.asp?eq=<%= Request.Querystring("eq") %>" onclick="flag=false">link1</a>

how can i get the xsl in the iframe to get the data, because right now i am being redirected to naverror.atm on the xsl unload. so it is not getting the onclick flag i send when clicking on the link
like i said the easy option would be to use AJAX,

First make frame 1 just a DIV with scrolling overflow, this looks like an iframe but is not.

Then surround your second iframe with a DIV, this will be sloppy but it requires less code modification.

then use AJAX to control the frames.

More code will follow.
Have a play with this:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>DIV Test</title>
</head>
<script language="javascript" type="text/javascript">
<!--
function Inline_Load(pagetoget, element_name){
//By EFFXDesign.com
var xmlHttp;
	try{xmlHttp=new XMLHttpRequest();}    // Firefox, Opera 8.0+, Safari
	catch (e){    // Internet Explorer
		try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
		catch (e){
			try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
			catch (e){
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}
    xmlHttp.onreadystatechange=function(){
		if(xmlHttp.readyState==4){
			document.getElementById(element_name).innerHTML=xmlHttp.responseText;
		}
	}
    xmlHttp.open("GET",pagetoget,true);
    xmlHttp.send(null);
}
//-->
</script>
<div id="topframe">
<a href="JavaScript:Inline_Load('test.asp', 'bottomframe');">Test</a><br />
<a href="JavaScript:Inline_Load('test1.asp', 'bottomframe');">Test 1</a><br />
<a href="JavaScript:Inline_Load('test2.asp', 'bottomframe');">Test 2</a><br />
<a href="JavaScript:Inline_Load('test3.asp', 'bottomframe');">Test 3</a>
</div>
<div id="bottomframe">Awaiting User Input</div>
</body>
</html>

Open in new window

Avatar of eaweb

ASKER

hi i solve it this way:

i put this part in the iframe page.

<script type="text/javascript" src="CSJSRequestObject.js"></script>

<script language="javascript">
   
      var tseq = Request.QueryString("TRANSEQ");

function OnloadTrigger()
{
var linkunload = window.parent.flag      
//alert(linkunload);      
}      

window.onload = OnloadTrigger;

function UnloadTrigger()
{            
      var linkunload = window.parent.flag
      if (linkunload)
      {      
      //alert(linkunload);
      top.window.location='naverror.atm?TRANSEQ='+tseq
      }else{                  
                  //alert(linkunload);                  
             }
}
window.onunload = UnloadTrigger;
Avatar of eaweb

ASKER

effx,

how can i use your ajax the othe way around.

the iframe need to get the onclick="flag=false" sent when clicking on the link from the main page
Try the ajax method it looks alot more cleaner.
Avatar of eaweb

ASKER

effx could explain me your code. what does it do actually? how do you pass for example the flag to the iframe?
ASKER CERTIFIED SOLUTION
Avatar of effx
effx
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial