Question

I have a link, when it clicks, It opens another window of browser (specialChars.php)

function popup_specialChars()
    {

        var ht;
        if(window.navigator.appVersion.indexOf("MSIE 5.01") == -1)
            ht = 300;
        else
            ht = 720;
        specialCharsWindow = window.open
        (
            "/TradeScienceJournalSystem/specialChars.php", "special_characters",
            "resizable=yes,scrollbars=yes,height=" + ht + ",width=650,dependent=yes,alwaysRaised=yes"
        );
        specialCharsWindow.focus();
    }

<a href="javascript:popup_specialChars();" class="special">Insert Special Character</a>
<textarea name="docArticleTitle" cols="60" rows="14"></textarea>

specialChars.php

function insert_text(str)
        {
                    alert(str);

            opener.append(str); // Not working
            this.window.focus();
        }

<table border="1" id="table1" width="97%">
                <tr>
                    <td align="center" class="specialcharlink"><a href="javascript:insert_text('&#x00E1;')"><span class="specialchar">&#x00E1;</span></a></td>
                </tr>
</table>

Now what happens when a link of a special character clicks, insert_text() will be called.and alert shows the special character.But I want to append that character into the textarea of the opener window.But It is not working.

How can I denote textarea of the opener window?

Was it helpful?

Solution

Gave an id to textarea

<textarea name="docArticleTitle" id="id1" cols="60" rows="14"></textarea>

And changed

function insert_text(str)
        {
                    window.opener.document.getElementById('id1').value += str;
                    this.window.focus();
        }

And its start appending characters to the textarea.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top