I import my css file and javascript files in index.xhtml
<script type="text/javascript" src="resource/js/bag.js"></script>
My project works like this in http://localhost:8084/Proje1/ . But when i open http://localhost:8084/Proje1/faces/index.xhtml this url, doesn't work. It doesn't find css file and jquery files. How can i fix this. Thank you.
Place your resource folder under WebContent, and replace your <script> import with this:
<script src="#{request.contextPath}/resource/js/bag.js"></script>
Related
I am new to Nodejs and having trouble when trying to export my js code which exists in HTML files to more js files for less redundancy in code (same js code in two HTML files):
I exported the js code from both HTML files to js a file (js_code_file.js for example) and tried using <script src="js_code_file.js" type="text/javascript"></script> in the header of the HTML file in order to import the file, and it did not work.
Is it because of Nodejs? and if it is - is there a way to "require" these files somehow?
<script src="js_code_file.js" type="text/javascript"></script>
Looking at the src attribute, js_code_file.js has to be in the same path as the .html file referencing it; that is, it has to literally be in the same folder. So make sure that is the case, otherwise, update your question with any errors you might be receiving.
I'm working on a simple project where I included a simple js file to fetch out a data from api on click of a button. It was working when I had HTML file and js file in same folder and used by simply clicking on index.html . Now i am using expressjs for same and written all the HTML code in index.ejs file. For some reason, the js file has stopped working. I have tried changing the paths and carefully defining the path, also kept the file in same folder as of ejs file but it does not seem to work. Any suggestions would be helpful. The lines I have included in ejs file as are as follows. Here the js file is in the js folder of public folder of the project
<script src="jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/script.js"></script>
I got this problem resolved by adding the following path to jQuery src
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"
instead of
"jquery-3.2.1.min.js"
I run a local installation of xampp on which a laravel 5.2 app is running. I am trying to include css and js files from the public directory, but none of the content of these files is being loaded.
Laravel finds the files, they are just always empty.
I tried to clear the browser cache and the Laravel cache, but neither worked. I have referenced the files in the following ways:
<script type="text/javascript" src="{{ asset('js/all.js') }}"></script>
OR
<script type="text/javascript" src="/js/all.js"></script>
In both cases the files are loaded, but does not contain anything.
I have tried generating the files through elixir or simply putting them directly in the folder, but still the same result.
Any help is appreciated.
Try this
<script type="text/javascript" src="{{ url('js/all.js') }}"></script>
Try this,
<script type="text/javascript" src="{{ URL::asset('js/all.js') }}"></script>
Here your js directory should be in the laravel's app/public folder and URL::asset() will produce the necessary url for you.
You can refer How to include css and js in Laravel 5 for more info.
Okay, so I didn't exactly solve the issue, but I got around it. Just posting answer for future reference.
I set up a virtual host i xampp to get around the files loading from localhost, like in this example: https://www.codementor.io/php/tutorial/how-to-install-laravel-5-xampp-windows
Afterwards the js and css files load on all the different options presented above. Apparently it is something to do with the .htaccess file in the root, when running from the default folder in xampp.
Thanks for all the suggestions.
Have you tried this?
<script src="{{URL::asset('/js/jquery-1.10.2.min.js')}}"> </script>
Make sure that the 'js' folder is inside the 'public' folder of your project.
I try to include *.js in [ *.component.html ] file
like this :
<script src="modal.js" type="text/javascript"></script>
but it doesn't load.
Only success I got , when I try to load *.js is in src/index.html.
I am a newbie at Angular2 ,I don't know how to load js flie in Angular 2 project .
any inputs?
<script> tags in templates are not added to the DOM, they are just stripped from the template. You need to use other means to add the script. For example require()
In the Jangaroo tutorial using Maven it states"include a Jangaroo application script generated by the Maven build process". This should be created in src/main/webapp/index.html, it isn't. Can anyone explain this, or what in the pox.xml is missing?
Thanks
The misunderstanding here is that actually, the Jangaroo application script is generated, not the index.html file.
The idea is that your index.html usually contains custom HTML, e.g. loading your CSS or setting up some context. The only Jangaroo-specific things your HTML code has to do is load the generated joo/jangaroo-application.js script and run the application's main class, using its fully-qualified name (in this example, HelloWorld is in the top-level package):
<script type="text/javascript"
src="joo/jangaroo-application.js"></script>
<script type="text/javascript">
joo.classLoader.run("HelloWorld");
</script>
https://github.com/CoreMedia/jangaroo-tools/wiki/Tutorial-~-Deployment