开发者

How can I print the contents of a js file to the screen from a URL?

I have an application that will check if a javascript file exists on our CDN and I would like to display the contents of that file in the browser window. I have all the nuts and bolts figured out, I just need to display 开发者_高级运维the contents of the javascript file when I put in the URL where it exists.

Thanks in advance.


I believe you can output a javascript file to a webpage by just making sure any html elements are escaped. You can use the htmleditformat() function to do this when you output the value.

For example:

<cfhttp url="#jsurl#"  />
<cfoutput><pre>#htmleditformat(cfhttp.filecontent)#</pre></cfoutput>

Other options just using the js address directly are to 1) link to the js file if you just want to be able to see it in the window, or 2) show the js file in an iframe


I'm not quite sure what you're asking:

  1. "I need to open a javascript file in a web browser" A. this is OS dependant, you call the binary that's registered for .htm files with parameters pointing it's initial destination to that .js file.

  2. "I have a web app and want to dynamically display the contents of remote files formatted as text" A. Use a block and fill it with GetWebResourceUrl().

  3. "I am writing a standalone app and want to display remote files as text" A. If you are writing a standalone, why do you want to display the contents of a js file via a browser? Use your local API, or launch the default text viewer with a local temp copy.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜