????? ????? ??? ? ?? ??? ?? JavaScript ??? ??? ?? Ruby on Rails ??????? ??? ???? ??? ?????. ?? ??, ?? ???, ?? ??? ?? ? ??? ?? ??? ???? ????? ?? ??? ??? ? ????. ???? ?? ??? ??? ???? ??? ???? ?? ??? ???????.
??
?1. 1??: ??
?2. 2??: ?????? ?? ?? ??
?3. 3??: Iframe? ?? ??(?? ??)
?4. 4??: Iframe ??? ?? ?? ??
?5. 5??: ?? ???
?6. 6??: ??? ??? ?? ? ????? ???? ?? ?? ??
1??: ??
? Rails ????? ??: ? ?????? ??? ?? JavaScript ??? ?????. ????? ?? WidgetsController ?? ??? ? ????.
# app/controllers/widgets_controller.rb class WidgetsController < ApplicationController def show # Your widget code here end end
?? ??: ??? ???? ? ??? ??? ?????.
# config/routes.rb Rails.application.routes.draw do get '/widget.js', to: 'widgets#show', as: :widget end
?????? JavaScript ??: Rails??? ??? ??? ??? ???? JavaScript? ??? ? ????.
# app/controllers/widgets_controller.rb class WidgetsController < ApplicationController def show response.headers['Content-Type'] = 'application/javascript' render layout: false end end
??? JavaScript ?? ??: ?? ?????? ????? ????? ???? ??? ?? HTML ?? ?? iframe? ????? ??? ???? ????.
// app/views/widgets/show.js.erb (function() { const widgetDiv = document.createElement('div'); widgetDiv.id = 'custom-widget'; widgetDiv.innerHTML = "<p>This is your custom widget content!</p>"; document.body.appendChild(widgetDiv); })();
2??: ?????? ?? ?? ??
?????? ??? ??? ? ??? ??? ???? HTML? ???? ? ?? JavaScript ???? ?????.
<!-- Client Embeddable Code --> <script type="text/javascript"> (function() { const script = document.createElement('script'); script.src = "https://yourapp.com/widget.js"; script.async = true; document.head.appendChild(script); })(); </script>
3??: Iframe? ?? ??(?? ??)
???? ?? ???? ????? iframe? ?? ???? ???? ?? ????. ? ?? ??? ??? ???? ??? ????? ???? ??? ?????.
??? iframe? ????? JavaScript ??? ???????.
// app/views/widgets/show.js.erb (function() { const iframe = document.createElement('iframe'); iframe.src = "<%= widget_content_url %>"; iframe.style.width = "300px"; iframe.style.height = "200px"; document.body.appendChild(iframe); })();
?? ???? ?? ? ?? ? ??? ?????.
# config/routes.rb Rails.application.routes.draw do get '/widget_content', to: 'widgets#content', as: :widget_content end
# app/controllers/widgets_controller.rb def content render layout: false end
?? ??? HTML ??: iframe ???? ???? ? ??
<!-- app/views/widgets/content.html.erb --> <div> <h2> Step 4: Setting Headers for Iframe Embedding </h2> <p>Configure the appropriate HTTP headers to ensure your widget works securely in an iframe. There are two primary headers to consider:</p> <p><strong>Remove the X-Frame-Options Header</strong>: The X-Frame-Options header is deprecated but still widely respected by many browsers. To remove it, add the following configuration in an initializer:<br> </p> <pre class="brush:php;toolbar:false"># config/initializers/security_headers.rb Rails.application.config.action_dispatch.default_headers.delete('X-Frame-Options')
Frame-Ancestors ??? ??:?? ????? ??? ?? ??? Frame-ancestors ???? ?? Content-Security-Policy? ???? ????. ?????. ?? ?? ??? ?? ??? ?? ? ??? ?????.
# config/initializers/security_headers.rb Rails.application.config.action_dispatch.default_headers.merge!({ 'Content-Security-Policy' => "frame-ancestors 'self' https://trusted-domain.com" })
? ??? ???? ??? ???? ???? ?? iframe? ??? ? ????. https://trusted-domain.com? ???? ?? ????? ????.
5??: ?? ???
??? ??? ??? ? ??? ????? ??? ???? ??? ???? ????? ???? ?????. ??? ?? ??? ??? ?? ??? ???? ??? ??? ? ?? ??? ???? ????? ?????.
6??: ??? ??? ?? ? ????? ???? ?? ?? ??
??? ???? ?? ?? ?????? ?? ??? ??? ?? ?? ??? ???? ?? ??? ??? ?? ????. ?? ??? ??? ???? ?? ???? ???? ????? ??? ?? ??? ???? ?? ??? ??? ?????? ? ????.
??? ??? ?? ? ????? ???? ?? ?? ??
??? ??? ?? ??
??? ? ??? ?? ??? ??? ???? ??? ?????. ? ??? ??????? ???? ??? ????? ???? ??? ??? ????? ??? ? ????.
# app/controllers/widgets_controller.rb class WidgetsController < ApplicationController def show # Your widget code here end end
??? ??? ???? ??
? ??? ?? ?? ?????? ?? ????? ????. ??? ???? ? ??? ?? ??? ?? ??? ??? ?? ????.
# config/routes.rb Rails.application.routes.draw do get '/widget.js', to: 'widgets#show', as: :widget end
# app/controllers/widgets_controller.rb class WidgetsController < ApplicationController def show response.headers['Content-Type'] = 'application/javascript' render layout: false end end
??? JavaScript ? HTML ?? ??
? ???? ??? JavaScript ? HTML ??? ???? ???? ??? ??? ?? ??? ? ????.
?? 1 ??????:
// app/views/widgets/show.js.erb (function() { const widgetDiv = document.createElement('div'); widgetDiv.id = 'custom-widget'; widgetDiv.innerHTML = "<p>This is your custom widget content!</p>"; document.body.appendChild(widgetDiv); })();
?? 1 ???:
<!-- Client Embeddable Code --> <script type="text/javascript"> (function() { const script = document.createElement('script'); script.src = "https://yourapp.com/widget.js"; script.async = true; document.head.appendChild(script); })(); </script>
?? 2 ???:
// app/views/widgets/show.js.erb (function() { const iframe = document.createElement('iframe'); iframe.src = "<%= widget_content_url %>"; iframe.style.width = "300px"; iframe.style.height = "200px"; document.body.appendChild(iframe); })();
?? ??
Rails ??????? ?? ?? ??? ???? JavaScript? ???? ????, ???? ????, iframe ???? ?? ??? ???? ???? ? ? ?? ?? ?? ??? ?????. ?? ??? ??? ??? ???? ?? ??? ? ?? ??? ?? ?? Rails ??????? ???? ??? ? ????.
? ??? Rails? ???? JS ??? ???? ??: ??? ???? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

Node.js?? HTTP ??? ???? ? ?? ???? ??? ????. 1. ?? ????? ????? ??? ??? ? ?? ????? ?? ?? ? https.get () ??? ?? ??? ??? ? ?? ????? ?? ??? ?????. 2.axios? ??? ???? ? ?? ??????. ??? ??? ??? ??? ??? ??? ???/???, ?? JSON ??, ???? ?? ?????. ??? ?? ??? ????? ?? ????. 3. ?? ??? ??? ??? ??? ???? ???? ??? ??? ???? ?????.

JavaScript ??? ??? ?? ?? ? ?? ???? ????. ?? ???? ???, ??, ??, ?, ???? ?? ? ??? ?????. ?? ????? ?? ?? ? ? ??? ????? ?? ??? ??? ????. ??, ?? ? ??? ?? ?? ??? ??? ??? ???? ??? ??? ???? ??? ?? ??? ????. ?? ? ????? ??? ???? ? ??? ? ??? TypeofNull? ??? ?????? ??? ? ????. ? ? ?? ??? ???? ?????? ????? ???? ??? ???? ? ??? ? ? ????.

?? JavaScript ??? ??? ??? ?????? ?? ??? ?? ?? ??? ?? ???? ????. 1. ??? ???? ???? ?? ??? ?? ? ? ???? ??? ??? ?? ? ?? ????? ?????. 2. Angular? ?????? ??? ?? ???? ? ?? ?? ??? ??? ??? ???? ?????. 3. VUE? ???? ?? ??? ???? ?? ?? ??? ?????. ?? ?? ?? ??, ? ??, ???? ???? ? SSR? ???? ??? ??? ??? ???? ? ??? ?????. ???, ??? ??? ??? ????? ????. ??? ??? ??? ??? ?? ????.

?????, JavaScript ???! ?? ? JavaScript ??? ?? ?? ?????! ?? ?? ??? ??? ??? ? ????. Deno?? Oracle? ?? ??, ??? JavaScript ?? ??? ????, Google Chrome ???? ? ??? ??? ???? ?????. ?????! Deno Oracle? "JavaScript"??? ????? Oracle? ?? ??? ??? ??????. Node.js? Deno? ??? ? Ryan Dahl? ??? ?????? ???? ????? JavaScript? ??? ???? Oracle? ????? ???? ?????.

??? JavaScript?? ??? ??? ?????? ?? ???????. ?? ??, ?? ?? ? ??? ??? ?? ????? ????? ?????. 1. ?? ??? ??? ????? ???? ??. ()? ?? ??? ??? ?????. ?. ()? ?? ??? ?? ??? ??? ?? ? ? ????. 2. ?? ??? .catch ()? ???? ?? ??? ??? ?? ??? ??????, ??? ???? ???? ????? ??? ? ????. 3. Promise.all ()? ?? ????? (?? ?? ?? ? ??????? ??), Promise.Race () (? ?? ??? ?? ?) ? Promise.AllSettled () (?? ??? ???? ??)

Cacheapi? ?????? ?? ???? ??? ???? ???, ?? ??? ??? ?? ???? ? ??? ?? ? ???? ??? ??????. 1. ???? ????, ??? ??, ?? ?? ?? ???? ???? ??? ? ????. 2. ??? ?? ?? ??? ?? ? ? ????. 3. ?? ?? ?? ?? ?? ??? ??? ?? ?????. 4. ??? ???? ?? ?? ???? ?? ?? ?? ?? ?? ???? ?? ?? ??? ??? ? ????. 5. ?? ???? ??, ??? ??? ? ??? ??, ?? ??? ? ?? ???? ???? ???? ? ?? ?????. 6.?? ??? ?? ?? ?? ??, ???? ?? ? HTTP ?? ????? ?????? ???????.

.map (), .filter () ? .reduce ()? ?? JavaScript ?? ?? ???? ??? ??? ??? ? ? ????. 1) .map ()? ??? ??? ??? ???? ? ??? ???? ? ?????. 2) .filter ()? ???? ??? ????? ? ?????. 3) .reduce ()? ???? ?? ??? ???? ? ?????. ???? ??? ????? ??? ?? ?? ??? ?????.

JavaScript? ??? ??? ?? ??, ? ? ? ?? ???? ???? ??? ??? ?????. 1. ?? ??? ?? ??? ???? ??? ??? ??? ??? ?? WebAPI? ?????. 2. WebAPI? ??????? ??? ?? ? ? ??? ?? ??? (??? ?? ?? ???? ??)? ????. 3. ??? ??? ?? ??? ?? ??? ?????. ?? ??? ??? ????? ??? ??? ?? ? ???? ?????. 4. ???? ?? (? : Promise. 5. ??? ??? ???? ?? ???? ???? ?? ?? ?? ??? ????? ? ??????.
