parent document question...
I created a form, that opens a new window with some more options...
now, once the user pushes a button on the newly opened window, I want some thins to happen in the main form window.
I know that if I want some values to change, all I need to do is :
parent.opener.document.getElementById("UserInput").value = usrValue;
now I wanna know, how to run a certain function on the main window, once a button on the new window was pushed???
thanks, gilly914
Re: parent document question...
To my knowledge this is impossible. I do not have time to research it now but I can look into it after work. The only thing I have ever seen is working with objects from other windows, never actual JavaScript function calls from other windows. Sorry.
Re: parent document question...
I just solved my problem, almost as usual, in a different way...
I just created a setInterval() to a function on the main window that checks if a certain flag is changed on the new window...
Than it knows when to activate...
Thanks for the help anyway... ;)
Re: parent document question...
Good thinking. I was thinking of using setTimeout but then I realized it couldn't be created dynamically. Then I thought to myself why not write it dynamically to a DIV?
Okay, here is another option... On the parent page create a DIV.
Code:
<div id="dynwrite" style="visibility:hidden"></div>
Now in the popup window write this...
Code:
<script language="JavaScript">
newhtmlline = "<script language='JavaScript'>";
newhtmlline = newhtmlline + "setTimeout('FUNCTIONNAME', 10);"
newhtmlline = newhtmlline + "</script>";
parent.opener.document.getElementByID('dynwrite').innerHTML = newhtmlline;
</script>
Re: parent document question...
Note that I edited my previous post and this will keep you from having to have an interval running and taking up resources.
Re: parent document question...
WOW!...
Thanks alot! You always supply me with good and creative solutions...
Thanks peejavery :)
Re: parent document question...
Quote:
Originally Posted by gilly914
WOW!...
Thanks alot! You always supply me with good and creative solutions...
Thank you too!
Re: parent document question...
This would look silly..
Keep a hidden button in the parent which calls a function on click.
Click this button from the popup.
as simple as that if u want it that way.
Re: parent document question...
Quote:
Originally Posted by amitvb
Keep a hidden button in the parent which calls a function on click.
Click this button from the popup.
Nice one. I tried the code below and it works nicely.
Code:
<input id="execbutton" type="button" value="Click Here" onclick="alert('It Worked!')" style="display:none">
<script language="JavaScript">
document.getElementById('execbutton').click();
</script>
One other thing, newer browsers even accept function calls between windows. I just found it and I never knew about it even though it seemed dumb to not work this way.
All you have to do is call the window's name and then the function.
Code:
windowname.window.function();
Sorry gilly914 for making that one hard on you.