How nginx returns a piece of js that can be executed on the client
PHPz
PHPz 2017-05-16 17:15:05
0
1
670

I want to use nginx configuration to automatically return a piece of js when accessing a certain URL, such as alert("some message")

I want to achieve this through the following configuration

location /foo {
          default_type application/javascript;
          return 200 '<script>alert("hello");</script>';
 }

But the actual access in the browser only returns text

<script>alert("hello");</script>

No dialog box pops up. Can nginx support returning js? How to configure it correctly?

PHPz
PHPz

学习是最好的投资!

reply all(1)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!