File tree Expand file tree Collapse file tree 2 files changed +31
-30
lines changed Expand file tree Collapse file tree 2 files changed +31
-30
lines changed Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ function renderContent ( ) {
4+ const urlHtml = document . querySelector ( '#urlHtml' ) . value ;
5+ const urlCss = document . querySelector ( '#urlCss' ) . value ;
6+
7+ renderContentInWindow ( urlHtml , urlCss ) ;
8+ }
9+
10+ function renderContentInWindow ( urlHtml , urlCss ) {
11+ const w = window . open ( ) ;
12+ w . document . open ( ) ;
13+ w . document . write ( "<h2>Hello World!</h2>" ) ;
14+ w . document . close ( ) ;
15+
16+ fetch ( urlHtml ) . then ( async res => {
17+ const html = await res . text ( ) ;
18+ const page = w . document . querySelector ( 'html' ) ;
19+ page . innerHTML = html ;
20+
21+ fetch ( urlCss ) . then ( async res => {
22+ const css = await res . text ( ) ;
23+ const style = w . document . createElement ( 'style' ) ;
24+ style . innerText = css ;
25+ const head = w . document . querySelector ( 'head' ) ;
26+ head . appendChild ( style ) ;
27+ } ) ;
28+
29+ } ) ;
30+ }
Original file line number Diff line number Diff line change @@ -108,36 +108,7 @@ <h1>Render Raw Gist</h1>
108108
109109 </ main >
110110
111- < script >
112- function renderContent ( ) {
113- const urlHtml = document . querySelector ( '#urlHtml' ) . value ;
114- const urlCss = document . querySelector ( '#urlCss' ) . value ;
115-
116- renderContentInWindow ( urlHtml , urlCss ) ;
117- }
118-
119- function renderContentInWindow ( urlHtml , urlCss ) {
120- const w = window . open ( ) ;
121- w . document . open ( ) ;
122- w . document . write ( "<h2>Hello World!</h2>" ) ;
123- w . document . close ( ) ;
124-
125- fetch ( urlHtml ) . then ( async res => {
126- const html = await res . text ( ) ;
127- const page = w . document . querySelector ( 'html' ) ;
128- page . innerHTML = html ;
129-
130- fetch ( urlCss ) . then ( async res => {
131- const css = await res . text ( ) ;
132- const style = w . document . createElement ( 'style' ) ;
133- style . innerText = css ;
134- const head = w . document . querySelector ( 'head' ) ;
135- head . appendChild ( style ) ;
136- } ) ;
137-
138- } ) ;
139- }
140- </ script >
111+ < script src ="app.js "> </ script >
141112
142113</ body >
143114
You can’t perform that action at this time.
0 commit comments