Event control between iFrame and parent window

J

Jayyde

Is there any way to capture a button click inside an iFrame and
perform both an action on that page and one on the parent page?

Basically I have a page atm that allows the user to add a record to a
table and what I would like to have are save and cancel buttons (or
maybe just a save button with a close image on the DHTML "window") on
the page that, when save is clicked for instance, will save the record
(code in that page) and close the DHTML window (code in the parent
page).

Any help would be greatly appreciated--I can't find anything in
searching that is quite the same as this :).

TIA,
Jayyde
 
A

Adambrz

Is there any way to capture a button click inside an iFrame and
perform both an action on that page and one on the parent page?

Basically I have a page atm that allows the user to add a record to a
table and what I would like to have are save and cancel buttons (or
maybe just a save button with a close image on the DHTML "window") on
the page that, when save is clicked for instance, will save the record
(code in that page) and close the DHTML window (code in the parent
page).

Any help would be greatly appreciated--I can't find anything in
searching that is quite the same as this :).

TIA,
Jayyde

Can you give an image of your layout to help understand your plan.
 
J

Jayyde

Can you give an image of your layout to help understand your plan.


Here's a screenie of an example of what I'm trying to do.

http://i59.photobucket.com/albums/g318/jayyde/javascript_group_screenie.png

There're 2 save buttons on there: the one on the iFrame page that's an
actual button, and the one in the div's title bar that's an image. I
don't really care which I use (I'd prefer just one or the other, not
both like I have it mocked up atm). Whichever one is easier to
accomplish my objective from is fine. I need it to do the following:

- Fire off a javascript function in the parent page
- Fire off an AJAX-ed ASP.NET method on the iFrame's src page
- Fire off an AJAX-ed ASP.NET method on the parent page
 
A

Adambrz

Here's a screenie of an example of what I'm trying to do.

http://i59.photobucket.com/albums/g318/jayyde/javascript_group_screen...

There're 2 save buttons on there: the one on the iFrame page that's an
actual button, and the one in the div's title bar that's an image. I
don't really care which I use (I'd prefer just one or the other, not
both like I have it mocked up atm). Whichever one is easier to
accomplish my objective from is fine. I need it to do the following:

- Fire off a javascript function in the parent page
- Fire off an AJAX-ed ASP.NET method on the iFrame's src page
- Fire off an AJAX-ed ASP.NET method on the parent page- Hide quoted text -

- Show quoted text -


I would start by getting rid of the iframe but you are the one design
not me I will help you the way you requested. You can have the Iframe
do its own thing and on Save(submit of form) it sends the variables to
a server-side script to save the data. at the end of that serverside
you could have a javascript line that states:

exerpt from(http://www.experts-exchange.com/Web/Web_Languages/
JavaScript/Q_21501305.html)

--mydiv.htm--
<script>
function hideIFrame()
{
document.getElementById("mydiv").style.display = "none";
}
</script>

<div id='mydiv'>
<iframe src='myiframe.htm'>

</iframe>
</div>

--myiframe.htm--
<script>
function AskParentToHideMe()
{
if (typeof(parent.hideIFrame)=='function') parent.hideIFrame();
}
</script>
<input type='button' value='Hide This IFrame'
onclick=AskParentToHideMe();">

Since the serverside runs before client-side you should get your
change to database while also making the div hide.

Hope that helps,
Adambrz
www.adambrz.com
 
J

Jayyde

I would start by getting rid of the iframe but you are the one design
not me I will help you the way you requested. You can have the Iframe
do its own thing and on Save(submit of form) it sends the variables to
a server-side script to save the data. at the end of that serverside
you could have a javascript line that states:

exerpt from(http://www.experts-exchange.com/Web/Web_Languages/
JavaScript/Q_21501305.html)

--mydiv.htm--
<script>
function hideIFrame()
{
document.getElementById("mydiv").style.display = "none";}

</script>

<div id='mydiv'>
<iframe src='myiframe.htm'>

</iframe>
</div>

--myiframe.htm--
<script>
function AskParentToHideMe()
{
if (typeof(parent.hideIFrame)=='function') parent.hideIFrame();}

</script>
<input type='button' value='Hide This IFrame'
onclick=AskParentToHideMe();">

Since the serverside runs before client-side you should get your
change to database while also making the div hide.

Hope that helps,
Adambrzwww.adambrz.com- Hide quoted text -

- Show quoted text -

Thanks for the help! :)

I don't think there is any way I can get away from using an iFrame,
since on that page (and another) there are mulitple Add New links like
the one I showed in the screenie. Each needs to have a slightly
different src on the iFrame (actually the same page, but different
data in the post). So it's not a static src, otherwise, yeah I just
wouldn't use an iFrame.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top