By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,827 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,827 IT Pros & Developers. It's quick & easy.

Event control between iFrame and parent window

P: n/a
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

Feb 6 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 6 Feb, 13:26, "Jayyde" <mirax...@yahoo.comwrote:
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.

Feb 6 '07 #2

P: n/a
On Feb 6, 4:18 pm, "Adambrz" <Adam...@msn.comwrote:
On 6 Feb, 13:26, "Jayyde" <mirax...@yahoo.comwrote:
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.

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

http://i59.photobucket.com/albums/g3...p_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

Feb 7 '07 #3

P: n/a
On Feb 7, 10:38 am, "Jayyde" <mirax...@yahoo.comwrote:
On Feb 6, 4:18 pm, "Adambrz" <Adam...@msn.comwrote:


On 6 Feb, 13:26, "Jayyde" <mirax...@yahoo.comwrote:
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.

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

http://i59.photobucket.com/albums/g3...t_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

Feb 9 '07 #4

P: n/a
On Feb 9, 1:49 pm, "Adambrz" <Adam...@msn.comwrote:
On Feb 7, 10:38 am, "Jayyde" <mirax...@yahoo.comwrote:


On Feb 6, 4:18 pm, "Adambrz" <Adam...@msn.comwrote:
On 6 Feb, 13:26, "Jayyde" <mirax...@yahoo.comwrote:
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.
Here's a screenie of an example of what I'm trying to do.
http://i59.photobucket.com/albums/g3...t_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,
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.

Feb 11 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.