高章伟
2022-02-24 81b0892b8c6aa064a9e8dbca09a8f7f1eb6de40e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<apex:page standardController="Quote" id="page11" showHeader="false" sidebar="false" pageStyle="Quote" >
    <script type="text/javascript">
        function closeMe() {
            top.window.close();
        }
        function sendText(str) {
            str = document.forms['{!$Component.mainForm}']['{!$Component.mainForm.page1.exceltext}'].value;
            //top.window.opener.excelImport(str);
            top.window.opener.excelImportGateway(str);
            top.window.close();
        }
        function setCB() {
            var userAgent = navigator.userAgent;
            var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1;
            var isEdge = userAgent.indexOf("Edge") > -1 && !isIE;
            var isIE11 = userAgent.indexOf('Trident') > -1 && userAgent.indexOf("rv:11.0") > -1;
            if (isIE|| isIE11 ){
             txt = window.clipboardData.getData("text");
             document.forms['{!$Component.mainForm}']['{!$Component.mainForm.page1.exceltext}'].value = txt;
            }else{
                try{
                    navigator.clipboard.readText().then(function(text){
                        document.getElementById('page11:mainForm:page1:exceltext').value =text ;
                    });
                }catch(err){
                    alert('粘贴失败!');
                }
            }
        }
    </script>
    <apex:form id="mainForm">
        <apex:pageBlock id="page1">
            <table>
                <tr>
                    <td><u><apex:outputLabel value="{!$Label.ImportText}"/></u></td>
                    <td colspan="2">&nbsp;</td>
                </tr>
                <tr>
                    <td colspan="2"><apex:outputLabel value="{!$Label.Tab_Text}"/></td>
                    <td><apex:commandButton onclick="setCB();return false;" style="width:100px" value="{!$Label.Paste_IE}" /></td>
                </tr>
                <tr>
                    <td colspan="3"><apex:inputTextarea style="width:350px;height:100px" id="exceltext"/></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><apex:commandButton onclick="closeMe()" style="width:100px" value="{!$Label.Cancel}"/></td>
                    <td><apex:commandButton onclick="sendText('dummy');return false;" style="width:100px" value="{!$Label.Registration}"/></td>
                </tr>
            </table>
        </apex:pageBlock>
    </apex:form>
</apex:page>