Kitty
Kitty

Reputation: 11

How to make a url from a popup window to be displayed on the parent window?

I have two pages, let's call them pageA.php and pageB.php.

Page A contains a textarea and a link. I want the link to open to pageB.php (a popup window). On pageB.php, there's a url that, when I click on it, the url will be displayed inside the textarea of pageA.php and pageB.php (the popup window) will close itself once I click on the url.

Upvotes: 1

Views: 1655

Answers (1)

amit_g
amit_g

Reputation: 31250

The link in the popup would be something like

<a href="Whatever" onclick="ProcessLinkClick(this);return false;">Click Me in Popup Window</a>

and the code would be (not tested and no error handling)

<script language="javascript">
function ProcessLinkClick(oThis) {
    if (window.parent) {
        var textBox = window.parent.document.getElementById("IdOfTextBoxInParentWindow");
        textBox.value = oThis.href;
    }

    window.close();
}
</script>

Upvotes: 1

Related Questions