I have created web application using xojo, while I have my own sample.js file
- Copy js file to same directory where project is located
- In "App->Header " I have added
- 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
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 :
This is in HandleSpecialURL :
Function HandleSpecialURL(Request As WebRequest) Handles HandleSpecialURL as Boolean
if Request.path = "sample.js" then
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 http://mygreatsite.com/framework/sample.js
where does the http://127.0.0.1/framework 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 http://127.0.0.1/
Is there anybody who knows path of http://127.0.0.1:8080/ 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.
HandleSpecialURL or HandleURL
If Request.Path = "myscript" then
request.print( MYCONSTANT )
request.status = 200
htmlheader or session html
It should just work fine.
Depending on your .htaccess <–
you could simply do this without handlespecialurl or handleurl.