Solved

DHTML Iframe closing window issue

Posted on 2007-12-04
2
1,409 Views
Last Modified: 2013-11-19
Hi Experts,

I am having issues closing a pop-up window on the click of a link.

Please see code for errors.

Basic Setup
Page 1
Has 1 Hidden and 1 Visible Input to be updated from another Source
Page 2
PopUp Iframe
Visit http://www.dynamicdrive.com/ for full source code
Inside Iframe
Page 3
Has Href to set off back to Original

Error I am getting is
ratewin is not defined
I have an alert in the main window, and the input boxes are being filled fine, just can't get the floating iframe to close after it has been used.
I put the close function back in the Parent Window as that is where it is defined?
I look forward to your thoughts and questions probably.

I am a bit of a newby to Java/ Ajax and DHTML
I am a VBA Programmer.
---Code to Open Window ----
<script type="text/javascript" src="../../dhtmlwindow/windowfiles/dhtmlwindow.js">
/***********************************************
* DHTML Window Widget- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
 
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
function OpenRateWin(BankCode) {
//alert (BankCode);
var ratewin = dhtmlwindow.open('Select Rate', 'iframe', '../Trans/AddBanksRatesMain_nh.asp?BankCode=' + BankCode, 'Select Rate', 'width=1000px,height=600px,center=1');
 
}
 
function closeRateWin_onchange() {
	alert("test");
	ratewin.close(); return false;
}
//-->
</SCRIPT>
 
--Href to Set off Code --
					Response.Write "<td class=BondsNav><a href=javascript:updaterateparent(" & rsD.Fields(i+1).Value & "," & rsD.Fields(i).Value & ") title=Use Rate>" & FormatNumber(rsD.Fields(i).Value, 2) & "</a></td>"				
 
--Java function this Href Runs --
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function updaterateparent(varRateID, txtRate) {
 
	if (typeof(parent.rate_onclick)=='function') parent.rate_onclick(varRateID, txtRate);
}
 
//-->
</SCRIPT>
-- Which in Turn runs --
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
function rate_onclick(varRateID, txtRate) {
	//alert(varRateID + txtRate);
     var winOpener = window.opener;
	 window.parent.Frmcheckall.txtRateID.value = varRateID;
     window.parent.Frmcheckall.txtRate.value = txtRate;
	//parent.closeRateWin_onchange(this);
	if (typeof(parent.closeRateWin_onchange)=='function') { 
		//alert("testIF");
		parent.closeRateWin_onchange();
	}
}
</SCRIPT>
-- Which leads me back to my original window to close its child iframe--

Open in new window

0
Comment
Question by:Craig Lambie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 250 total points
ID: 20403528
You have declared the variable as a local variable in the functon, so it doesn't exist outside the function. Declare it outside the function:
var ratewin;
 
function OpenRateWin(BankCode) {
  ratewin = dhtmlwindow.open('Select Rate', 'iframe', '../Trans/AddBanksRatesMain_nh.asp?BankCode=' + BankCode, 'Select Rate', 'width=1000px,height=600px,center=1');
}

Open in new window

0
 
LVL 1

Author Comment

by:Craig Lambie
ID: 20403625
You little Beauty!!!
Thanks so much!! Just couldn't see it...
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question