JavaScript ?

AD Design

New Member
Hello all. I hope this is the right forum for this question. If not and someone can point me in the right direction it is greatly appreciated.

I am currently trying to figure out how to change the contents of the "parent" window from the "child" window that was opened via a link in the "parent" window. I am opening a new window to show a sample of a project in a particular category and want to include a link that says something like "view more samples of (i.e.) brochures in our 'Portfolio section' having the word "portfolio" be a rollover that when clicked refreshes the parent window with the portfolio homepage.

Hope this makes sense. If not, I may be able to post live files for preview.

Thanks!

Sara
 

AD Design

New Member
Here's the code I'm currently working with

Hi. I'm working out of the book "Visual Quickstart Guide: JavaScript for the World Wide Web" and have the following beginning of the code to include in the "child" window:

function updateParent() {
opener.document


The book then goes into code for changing a form box, so I'm not sure how to edit this so that it changes the entire page to the portfolio homepage after clicking the "portfolio" link in the child window.


Thanks for any help.

S
 

Arkette

New Member
It's quite a while since I worked with the window.parent part of the DOM but, I think I'm right in saying that you can only write to a parent window but that you cannot cause the window to call back so what you want would not be possible. Unless that is, there is a way to trigger events in the parent window, but I'm not sure that's possible either, but it might be worth researching.
 

AD Design

New Member
Something like this . . .

Thank you for your response. I'm looking to do something similar to what happens the first time you visit this site: http://www.commarts.com

The only difference is that I don't want to automatically open the child window when someone gets to a certain page, they will open the child window via a link. But the idea that they can then click within that child window and change the parent window and also simulatenously close the child window is ultimately what I want to do (i.e. example above).

I am going to review the code from this site, however, is it illegal to work from it?

Thanks!

S
 

Arkette

New Member
The site you referenced uses a frameset and the child window is calling new content into a frame in the parent. This is relatively easy to do parent.frame.actioncall. However Frames and Framesets are deprecated technology, so whatever you do, don't go down that road. As for peeking at the code and markup from other sites it's fairly common practice if you're just looking for ideas, but don't just lift chunks of code without the authors permission, because that's copyright infringement.
 

abzu

New Member
If I have this right, you want to have one window open another window. Then you want a link in the second window that both closes itself and changes the content of the first window. if this is correct then it is extremely easy:

put something like this into the head of your child window
Code:
<script language="JavaScript" type="text/JavaScript">
function parent_change(url)
{
	opener.location.href = url;
	window.close();
}
</script>


Then call the function with your link in the body like this
Code:
<a href="javascript:parent_change('http://www.google.com')">
Change your Parent page to google
</A>

Obviously you won't want to link to google but I think you get the idea.
 
Last edited:
Top