How add own local machine js in debug and release?

I have created web application using xojo, while I have my own sample.js file

  1. Copy js file to same directory where project is located
  2. In "App->Header " I have added <script src ="../sample.js" type="text/javascript" charset="UTF-8"></script>
  3. Run app : while inspect element, it shows 404 error with

I checked that I need to use Insert -> copy file. Please suggest how do I add script from local machine?

What are you trying to achieve with a SRC in the app header ? Think of it as in a regular HTML page.

What does sample.js do ? Does it simply contain functions or something else ?

Indeed, you need to make sample.js file available. Which platform will you be on eventually ? (debug and release may be different)

sample.js contains hardware function like check for hardware drivers is installed or not.
For testing and debugging purpose it is sample.js is on my local machine
And I placed in . and when I run web app on browser , browser unable to find sample.js because sample.js is on user/desktop/myapplication/sample.js directory. and I have given <script src ="../sample.js" type="text/javascript" charset="UTF-8"></script> .
Thats all.
I need a right path or whatever in so browser could load it.

Is it a standalone or cgi app ?

In a cgi app, you can upload the js file and simply point to it.

In a standalone app (which is the case for debug), you need to create a WebFile, which means you cannot do a static reference in App.Header, since the WebFile changes path each time it is created.

OK. Here is how you do in a Standalone app :

This goes into App.HTMLHeader :

<script src ="" type="text/javascript" charset="UTF-8"></script> 

This is in HandleSpecialURL :

Function HandleSpecialURL(Request As WebRequest) Handles HandleSpecialURL as Boolean if Request.path = "sample.js" then request.print sample return true end if End Function

I have put my own functions in a constant called “sample”. You can load your sample.js into a variable with Texinputstream so it gets all the necessary content.

For a cgi app, you will have to enter the exact URL of the app in HTMLHeader, for instance

Or simply point to URL of the file in the directory you created for it, and there is no need for HandleSpecialURL.

That will be nice and I got your point,
This may be one way, but what if I place the sample.js to framework directory like you suggested
where does the located?
If it is created on runtime then how could I copy sample.js to framework directory.
There may be also other directoris such as Resource.
Please suggest how could I copy sample.js to framework or Resource directoy of

Is there anybody who knows path of while running web app?
I have wasted my whole day to investigating how to add .js file to xojo web app.
@Michel Bujardet : suggested answer is nice but is not useful way. I need to add js file on tag anyhow,

Please suggest steps or link. May be there is very simple solution.

Michel’s way is pretty much the simplest way to do it.
If you’re going to get more complex than that, you should look at the WebSDK for creating custom controls.

I have given all information to work this out.

Before I posted, I tested every single line of code. As we say in the twelve steps programs, it works if you work it.

You may need a bit of practical knowledge of web hosting, though.

you can place the javascript in a (app or module) constant then have HandleSpecialURL or HandleURL give it as a response to the

HandleSpecialURL or HandleURL

If Request.Path = "myscript" then
request.print( MYCONSTANT )
request.status = 200
return true
end if

Set mime or content type to “text/javascript”


htmlheader or session html

It should just work fine.

Depending on your .htaccess <–
you could simply do this without handlespecialurl or handleurl.