p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Beginning JavaScript 2nd Edition (http://p2p.wrox.com/book-beginning-javascript-2nd-edition-128/)
-   -   can any1 solve window.open() and window.opener issues (http://p2p.wrox.com/book-beginning-javascript-2nd-edition/78806-can-any1-solve-window-open-window-opener-issues.html)

abhihello123 April 1st, 2010 11:01 AM

can any1 solve window.open() and window.opener issues
 
I'm doing a lil experiment on window.open to achieve certain result. Its something like when I open exp.htm and click on the link an existing page paintParent.htm should open and it has 1line of text in it. Through exp.htm we are appending one line of text to paintParent.htm. paintParent.htm is changing background color of exp.htm The codes are given below --

exp.htm
--------


<html>
<head>
<script type="text/javascript">

function openNewLink() {

var newwindow = window.open("paintParent.htm","mywindow","width=40 0,height=300");
//newwindow.focus();

newwindow.document.open();
newwindow.document.write("<b>this is exp.htm</b>");
newwindow.document.close();

return false;

}
</script>
</head>

<body>
<p> Click below to open paintParent.htm page and it will also change backcolor of this page to

red</p>

<a href="" onclick = "return openNewLink()">click here</a>
</body>

</html>


paintParent.htm
---------------


<html>
<script type="text/javascript">
//this file will paint exp.htm when that file is opened.

document.write("this is paintParent.htm");
window.opener.document.bgcolor = "RED";

</script>
</html>

PeterPeiGuo April 1st, 2010 11:31 AM

spell bgColor with captial C:
Code:

<html>
<script type="text/javascript">
//this file will paint exp.htm when that file is opened.

document.write("this is paintParent.htm");
window.opener.document.bgColor = "RED";

</script>
</html>


abhihello123 April 1st, 2010 12:42 PM

Thank You Peter for your reply. Actually after posting this I too realised this mistake. The problem now exists is that I'm expecting ouput in the new window opened as -

this is paintParent.htm this is exp.htm but this is only printing
this is exp.htm. Why is it not printing this is paintParent.htm?

also I have been using notepad as well as visual studio for writing javascript codes but not satisfied...


All times are GMT -4. The time now is 10:36 AM.

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.