teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

5

OSやブラウザのバージョンを明記しました。

2017/07/08 04:13

投稿

ubon
ubon

スコア68

title CHANGED
File without changes
body CHANGED
@@ -1,11 +1,12 @@
1
+ Window10 Pro 64bit バージョン 1703 OSビルド 15063.413
1
- Window10 64bit Chrome/IE11 VS2013 Community Update5環境において
2
+ Chrome/IE11 VS2013 Community Update5環境において
2
3
  CrystalReportsにてASP.NETのプログラムを作成しております。
3
4
 
4
5
  子ウインドウ(A)から、さらにPDF出力用の子ウインドウ(B)をOpenし、
5
6
  下記の記事を参考に、javascriptによってwindow.open直後に
6
7
  POSTをするという方法でパラメータを渡して
7
8
  PDFをストリーム経由で(B)に出力するというプログラムを作成していたところ
8
- Chromeでは問題ないのですが、IE11では子ウインドウは開くものの
9
+ Chromeでは問題ないのですが、IE11(11.413.15063.0)では子ウインドウは開くものの
9
10
  画面が真っ白のまま読み込みが終了してしまいます。
10
11
 
11
12
  http://qiita.com/tsunet111/items/0167704a65ebc04411f9

4

開発環境について追記

2017/07/08 04:13

投稿

ubon
ubon

スコア68

title CHANGED
File without changes
body CHANGED
@@ -1,4 +1,5 @@
1
- Window10 64bit Chrome/IE11 VS2013 CrystalReportsてASP.NETのプログラムを作成してります。
1
+ Window10 64bit Chrome/IE11 VS2013 Community Update5環境において
2
+ CrystalReportsにてASP.NETのプログラムを作成しております。
2
3
 
3
4
  子ウインドウ(A)から、さらにPDF出力用の子ウインドウ(B)をOpenし、
4
5
  下記の記事を参考に、javascriptによってwindow.open直後に

3

注釈を追記しました。

2017/06/29 02:51

投稿

ubon
ubon

スコア68

title CHANGED
File without changes
body CHANGED
@@ -91,7 +91,7 @@
91
91
  </html>
92
92
 
93
93
  ```
94
- <out.aspx.vb> ※out.aspxは特に編集無し
94
+ <out.aspx.vb> ※out.aspxは特に編集無し。sample.pdfは1ページの簡単なpdfを使用。
95
95
  ```lang-vb.net
96
96
  Imports System
97
97
  Imports System.IO

2

サンプルコードを修正し、Fiddlerでのキャプチャ結果を追記いたしました。

2017/06/29 00:59

投稿

ubon
ubon

スコア68

title CHANGED
File without changes
body CHANGED
@@ -17,43 +17,148 @@
17
17
 
18
18
  本件CrystalReportsは記載させていただいておりますが
19
19
  関係ないと判断しております。その根拠としては
20
- Windows7環境ではChrome/IE11ともに動作確認済みのrptファイルと
20
+ Windows7環境ではChrome/IE11ともに動作確認済みのrptファイルと
21
21
  PDF出力のロジックをそのまま利用して、window.openの部分を切り替えることによって
22
22
  現象が発生するかしないかが切り替わることを確認したためです。
23
23
 
24
+ ---
24
- うまくいかないパタ
25
+ **2017.06.29 コドを修正しました。**
26
+ base.aspxをスタートアップとし、baseにあるボタンから、out.aspxでストリーム出力させるサンプルコードです。
25
- Windows10 64bit Chrome ○ **IE11 ×**
27
+ <base.aspx> base.aspx.vbファイルは編集無し
26
- Windows7 32bit Chrome ○ IE11 ○
27
- ```javascript
28
+ ```lang-aspx
28
- window.open('', 'report');
29
+ <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="base.aspx.vb" Inherits="WebApplication1.base" %>
29
30
 
30
- var form = $('<form/>', {
31
- id: 'rpt_p',
32
- action: 'out_pdf.aspx?type=hist',
33
- target: 'report',
34
- method: 'post'
31
+ <!DOCTYPE html>
35
- }).append($('<input/>').attr({
36
- type: 'hidden',
37
- id: 'rpt_hidP',
38
- name: 'rpt_hidP',
39
- value: $('#hidP').val()
40
- })
41
- );
42
32
 
33
+ <html xmlns="http://www.w3.org/1999/xhtml">
43
- $('body').append(form);
34
+ <head runat="server">
35
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
36
+ <meta http-equiv="content-language" content="ja" />
37
+ <meta http-equiv="x-ua-compatible" content="IE=10" />
38
+ <meta http-equiv="x-ua-compatible" content="IE=EmulateIE10" />
39
+ <title>output test</title>
40
+ <script src="jquery.min.js" type="text/javascript"></script>
44
41
 
45
- $('#rpt_p').submit();
42
+ <script type="text/javascript">
46
- $('#rpt_p').remove();
43
+ $(function () {
47
44
 
48
- form = null;
45
+ $('#btn_ok').click(function () {
49
46
 
47
+ window.open('out.aspx?type=hist&rpt_hidP=' + 'dummy', '_blank');
48
+
49
+ });
50
+
51
+ $('#btn_dame').click(function () {
52
+
53
+ window.open('', 'report');
54
+
55
+ var form = $('<form/>', {
56
+ id: 'rpt_p',
57
+ action: 'out.aspx?type=hist',
58
+ target: 'report',
59
+ method: 'post'
60
+ }).append($('<input/>').attr({
61
+ type: 'hidden',
62
+ id: 'rpt_hidP',
63
+ name: 'rpt_hidP',
64
+ value: 'dummy'
65
+ })
66
+ );
67
+
68
+ $('body').append(form);
69
+
70
+ $('#rpt_p').submit();
71
+ $('#rpt_p').remove();
72
+
73
+ form = null;
74
+
75
+ });
76
+
77
+ });
78
+ </script>
79
+ </head>
80
+ <body>
81
+ <form id="form1" runat="server">
82
+ <div>
83
+
84
+ <input type="button" id="btn_ok" value="OKパターン" />
85
+
86
+ <input type="button" id="btn_dame" value="ダメパターン" />
87
+
88
+ </div>
89
+ </form>
90
+ </body>
91
+ </html>
92
+
50
93
  ```
94
+ <out.aspx.vb> ※out.aspxは特に編集無し
95
+ ```lang-vb.net
96
+ Imports System
97
+ Imports System.IO
98
+
99
+ Public Class out
100
+ Inherits System.Web.UI.Page
101
+
102
+ Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
103
+
104
+ Response.Cache.SetCacheability(HttpCacheability.NoCache)
105
+ Response.Cache.SetNoStore()
106
+
107
+ Dim bLength As Byte()
108
+
109
+ 'ファイルを開く
110
+ Dim fs As New System.IO.FileStream(HttpContext.Current.Server.MapPath("pdf/sample.pdf"), System.IO.FileMode.Open, System.IO.FileAccess.Read)
111
+
112
+ 'ファイルを読み込むバイト型配列を作成する
113
+ ReDim bLength(fs.Length)
114
+ 'ファイルの内容をすべて読み込む
115
+ fs.Read(bLength, 0, Convert.ToInt32(bLength.Length))
51
- うまくいくパターン
116
+ '閉じる
117
+ fs.Close()
118
+
119
+ Response.ClearHeaders()
120
+ Response.ClearContent()
121
+ Response.ContentType = "Application/pdf"
122
+
123
+ ' ダイアログ表示
124
+ Response.AddHeader("content-disposition", "inline; filename=" & System.Web.HttpUtility.UrlEncode("sample.pdf"))
125
+
126
+ ' HTTP 出力ストリームに書き込み
127
+ Response.BinaryWrite(bLength)
128
+ Response.End()
129
+
130
+ End Sub
131
+
132
+ End Class
133
+ ```
134
+ OKパターン ボタン 結果
52
135
  Windows10 64bit Chrome ○ **IE11 ○**
53
136
  Windows7 32bit Chrome ○ IE11 ○
137
+
54
- ```javascript
138
+ ダメパターン ボタン 結果
139
+ Windows10 64bit Chrome ○ **IE11 ×**
140
+ Windows7 32bit Chrome ○ IE11 ○
141
+
142
+ 上記のサンプルでも再現することからもrptは関係ないと思われます。
143
+
144
+ さらに、SurferOnWwwさんからアドバイスいただいたようにFiddlerでキャプチャした結果
145
+
146
+ OKパターンのキャプチャ
55
- window.open('out_pdf.aspx?type=hist&rpt_hidP=' + $.trim($('#hidP').val()), '_blank');
147
+ リクエストヘッダー GET /out?type=hist&rpt_hidP=dummy HTTP/1.1
148
+ レスポンスヘッダー HTTP/1.1 200 OK
149
+
150
+ ダメパターンのキャプチャ
151
+ リクエストヘッダー POST /out.aspx?type=hist HTTP/1.1
152
+ レスポンスヘッダー HTTP/1.1 301 Moved Permanently となり下記のような
153
+ HTMLが出力された後 Location: /out?type=hist でリダイレクトされているという違いが明らかになりました。
154
+ ```html
155
+ <html><head><title>Object moved</title></head><body>
156
+ <h2>Object moved to <a href="/out?type=hist">here</a>.</h2>
157
+ </body></html>
56
158
  ```
159
+
160
+ Chromeでも同様のキャプチャ結果となりましたが、動作しております。
161
+
57
162
  パラメータが多くなる可能性があるため、できればPOSTで解決したいと
58
163
  考えております。
59
164
  対応方法ご存知の方、どうぞよろしくお願いいたします。

1

具体的なサンプルコードを掲載しました。

2017/06/29 00:29

投稿

ubon
ubon

スコア68

title CHANGED
File without changes
body CHANGED
@@ -15,6 +15,45 @@
15
15
  というjavascriptの処理の中で対応が必要か?というところで
16
16
  行き詰っております。
17
17
 
18
+ 本件CrystalReportsは記載させていただいておりますが
19
+ 関係ないと判断しております。その根拠としては
20
+ Windows7環境ではChrome/IE11ともに動作確認済みのrptファイルと
21
+ PDF出力のロジックをそのまま利用して、window.openの部分を切り替えることによって
22
+ 現象が発生するかしないかが切り替わることを確認したためです。
23
+
24
+ うまくいかないパターン
25
+ Windows10 64bit Chrome ○ **IE11 ×**
26
+ Windows7 32bit Chrome ○ IE11 ○
27
+ ```javascript
28
+ window.open('', 'report');
29
+
30
+ var form = $('<form/>', {
31
+ id: 'rpt_p',
32
+ action: 'out_pdf.aspx?type=hist',
33
+ target: 'report',
34
+ method: 'post'
35
+ }).append($('<input/>').attr({
36
+ type: 'hidden',
37
+ id: 'rpt_hidP',
38
+ name: 'rpt_hidP',
39
+ value: $('#hidP').val()
40
+ })
41
+ );
42
+
43
+ $('body').append(form);
44
+
45
+ $('#rpt_p').submit();
46
+ $('#rpt_p').remove();
47
+
48
+ form = null;
49
+
50
+ ```
51
+ うまくいくパターン
52
+ Windows10 64bit Chrome ○ **IE11 ○**
53
+ Windows7 32bit Chrome ○ IE11 ○
54
+ ```javascript
55
+ window.open('out_pdf.aspx?type=hist&rpt_hidP=' + $.trim($('#hidP').val()), '_blank');
56
+ ```
18
57
  パラメータが多くなる可能性があるため、できればPOSTで解決したいと
19
58
  考えております。
20
59
  対応方法ご存知の方、どうぞよろしくお願いいたします。