php - 如何将字符 append 到父窗口的组件

标签 php javascript append special-characters window.opener

我有一个链接,当点击它时,它会打开另一个浏览器窗口(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>

现在,当单击特殊字符的链接时会发生什么,将调用 insert_text()。并且警报显示特殊字符。但是我想将该字符 append 到打开器窗口的文本区域中。但是它不起作用。

如何表示打开窗口的文本区域?

最佳答案

给textarea一个id

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

改变了

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

它开始将字符 append 到文本区域。

关于php - 如何将字符 append 到父窗口的组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16211480/

相关文章:

javascript - eval() 读取函数参数有多糟糕

javascript - jQuery Toggle 随机刷新屏幕

javascript - 如何在调整大小时追加/删除元素而不重复它们

css - append 模态 : how to fadeIn the background (parent) but not the modal content (child)

PHP 类在运行 PHPUnit 测试用例时解决同一目录中类的问题

php - Symfony 2 - 如何保持两个 symfony 应用程序之间的模型同步

php - 将 WordPress 网站从实时迁移到本地时,特色图像被破坏

php - Symfony2 FOSRestBundle handleView() 不起作用

javascript - JQuery 切换并删除多个 div 中的 css 类

python - 如何在列表中找到相同的值并将新列表组合在一起?