質問編集履歴

2

javascript更新

2016/08/30 01:46

投稿

shikasama
shikasama

スコア163

test CHANGED
File without changes
test CHANGED
@@ -50,43 +50,53 @@
50
50
 
51
51
  function showNewWindow(manageNo) {
52
52
 
53
- var url = '../SelectOutputForm/子ウィンドウ?no=' + manageNo;
53
+ var w_size = 200;
54
54
 
55
- var ret;
55
+ var h_size = 260;
56
56
 
57
- var userAgent = window.navigator.userAgent.toLowerCase();
57
+ var ret = '';
58
58
 
59
- if (userAgent.indexOf('trident/7') != -1) {
59
+ var openWindow = open(url, '_blank', 'height=' + w_size + ',width=' + h_size + ',height=' + h_size);
60
60
 
61
- ret = showModalDialog('../SelectOutputForm/子ウィンドウ' + manageNo, window, 'dialogheight:200px;dialogwidth:260px;');
62
61
 
63
- } else {
64
62
 
65
- open('../SelectOutputForm/子ウィンドウ', window, 'dialogheight:200px;dialogwidth:260px;');
63
+ if (window.addEventListener) {
66
64
 
67
65
  window.addEventListener('message', function (event) {
68
66
 
69
67
  ret = event.data
70
68
 
69
+ outputExcel(ret, manageNo);
70
+
71
+ }, false);
72
+
73
+ } else if (window.attachEvent) {
74
+
75
+ window.attachEvent('message', function (event) {
76
+
77
+ ret = event.data
78
+
79
+ outputExcel(ret, manageNo);
80
+
71
- })
81
+ });
72
82
 
73
83
  }
74
84
 
85
+ }
75
86
 
87
+
88
+
89
+ function outputExcel(ret, manageNo) {
76
90
 
77
91
  if ('html' == ret) {
78
92
 
79
93
  return sendPostNewWindow(document.forms[0], '../Excel/Present?no=' + manageNo);
80
94
 
81
- } else if (('xlsx' == ret)) {
95
+ } else {
82
96
 
83
- // Excel出力処理
97
+ //処理
84
98
 
85
- } else if ('close' == ret) {
86
-
87
- return;
88
-
89
- }
99
+ }
90
100
 
91
101
  }
92
102
 

1

コード追加

2016/08/30 01:46

投稿

shikasama
shikasama

スコア163

test CHANGED
File without changes
test CHANGED
@@ -19,3 +19,105 @@
19
19
  変数を返すことができるみたいなのですがwindow.openでも同様のことをしたいと思います.
20
20
 
21
21
  どのようにしたら実現可能でしょうか?ご教示ください.
22
+
23
+
24
+
25
+ 追記
26
+
27
+
28
+
29
+ 親ウィンドウ
30
+
31
+ ```html
32
+
33
+ <head>
34
+
35
+ <script type="text/javascript" src="@Url.Content("~/Scripts/output.js")"></script>
36
+
37
+ </head>
38
+
39
+ <body>
40
+
41
+ <button type="button" onclick="showNewWindow(1) %>);">出力</button>
42
+
43
+ </body>
44
+
45
+ ```
46
+
47
+ output.js
48
+
49
+ ```javascript
50
+
51
+ function showNewWindow(manageNo) {
52
+
53
+ var url = '../SelectOutputForm/子ウィンドウ?no=' + manageNo;
54
+
55
+ var ret;
56
+
57
+ var userAgent = window.navigator.userAgent.toLowerCase();
58
+
59
+ if (userAgent.indexOf('trident/7') != -1) {
60
+
61
+ ret = showModalDialog('../SelectOutputForm/子ウィンドウ' + manageNo, window, 'dialogheight:200px;dialogwidth:260px;');
62
+
63
+ } else {
64
+
65
+ open('../SelectOutputForm/子ウィンドウ', window, 'dialogheight:200px;dialogwidth:260px;');
66
+
67
+ window.addEventListener('message', function (event) {
68
+
69
+ ret = event.data
70
+
71
+ })
72
+
73
+ }
74
+
75
+
76
+
77
+ if ('html' == ret) {
78
+
79
+ return sendPostNewWindow(document.forms[0], '../Excel/Present?no=' + manageNo);
80
+
81
+ } else if (('xlsx' == ret)) {
82
+
83
+ // Excel出力処理
84
+
85
+ } else if ('close' == ret) {
86
+
87
+ return;
88
+
89
+ }
90
+
91
+ }
92
+
93
+
94
+
95
+ function returnMessage(text) {
96
+
97
+ window.opener.postMessage(text, '*');
98
+
99
+ window.close()
100
+
101
+ }
102
+
103
+ ```
104
+
105
+
106
+
107
+ 子ウィンドウ
108
+
109
+ ```html
110
+
111
+ <head>
112
+
113
+ <script type="text/javascript" src="@Url.Content("~/Scripts/output.js")"></script>
114
+
115
+ </head>
116
+
117
+ <body>
118
+
119
+ <input type="button" name="xlxsButton" style="width:200px;" value="button" onclick="returnMessage('html');">
120
+
121
+ </body>
122
+
123
+ ```