Executing a JavaScript file directly from the browser

前端 未结 6 1119
攒了一身酷
攒了一身酷 2021-01-31 04:31

This sounds like a trivia question but I really need to know.

If you put the URL of an HTML file in the Location bar of your browser, it will render that HTML. That\'s

6条回答
  •  庸人自扰
    2021-01-31 05:23

    Not directly, but you could make a simple server-side script, e.g. in PHP. Instead of

    http://example.com/file.js
    

    , navigate to:

    http://localhost/execute_script.php?url=http://example.com/file.js
    

    Of course, you could smallen this by using RewriteRule in Apache, and/or adding another entry in your hosts file that redirects to 127.0.0.1.

    Note that this is not great in terms of security, but if you use it yourself and know what you're downloading, you should be fine.

    
     
    
      
    
     
    
     
    
     
    
    

提交回复
热议问题