...

View Full Version : Posting text from child windo to opener window



ehasan
03-16-2005, 05:33 PM
Hi There,

I am a newbie in this javascript world and also in this forum. I have run into a very strange problem.

I have a page which opens a new popup window and on that window, after clicking on a link, the content of a textbox must go to the parent (opener) window's textbox. I have used the following code and it works fine in my localhost. But, after I upload it to my server, and run from then, IE shows a "Access is denied" error message...........can any1 help me resolve this issue ??

Here is the main page code:

<script LANGUAGE="JavaScript">
<!--
var newwindow = '';

function popitup(url)
{
if (!newwindow.closed && newwindow.location)
{
newwindow.location.href = url;
}
else
{
newwindow=window.open(url,'name','height=460,width=600');
if (!newwindow.opener) newwindow.opener = self;
}
if (window.focus) {newwindow.focus()}
return false;
}

function setHTML(val ) {
var f = document.oArticleForm;
if (val != '') {
f.campaign_article_text.value = val;
}
}

// End -->
</script>

Fill out the following information as needed:
<form method="POST" name="oArticleForm" action="/myCampaignManager/index.php">
<table>
<tr>
<td align="right"><textarea NAME="campaign_article_text" rows="10" cols="70"></textarea>
<br>
<a href="#" onclick="popitup('http://www.itestweb.com/spaw/edit.php')">Edit in WYSIWYG Editor </a></td>
</tr>

..............

And the child window (edit.php), has the following code:

<script LANGUAGE="JavaScript">
<!--
function refreshForm() {
var newHTML = document.forms.HTML.spawHTML.value;
window.opener.setHTML(newHTML);
return false;
}
// End -->
</script>

<form name="HTML" action="#" method="post" onSubmit="return refreshForm();">

.............

<input type="submit" name="Submit" value=" Save ">
</form>

...........

glenngv
03-17-2005, 01:52 AM
Are the two pages in the same domain? For security reasons, a site cannot access any content from external sites and vice versa.

ehasan
03-17-2005, 01:57 AM
Are the two pages in the same domain? For security reasons, a site cannot access any content from external sites and vice versa.

Yes, both of them are in the same domain and in the same directory. However, I have discovered some more ridiculous fact. If I put both of them in a normal file, they work just fine. But, they wont work from my script. If you want to have a look at the main script, let me know. It will be of great help.

Thanks for your reply.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum