I downloaded some realtime css editor and I have a hard time figuring out how to link it to my other pages.
I have a file called cssit.js (that's a css editor) and if I put it in a same folder as my page, it works fine. However, if I wish to link to that script from pages that are in other folders, I don't know how to.
Example: My page is in images/index.php, but that script is in scripts/javascript/cssit.js
How would I link to index.php that script?
// images/index.php
<script src="../scripts/javascript/cssit.js">
// another/dir/index.php
<script src="../../scripts/javascript/cssit.js">
Or, maybe an easier way is to use absolute paths. Assuming scripts/javascript is at the root of your website:
// images/index.php
<script src="/scripts/javascript/cssit.js">
// another/dir/index.php
<script src="/scripts/javascript/cssit.js">
Related
I've just moved to github pages, and I have an index.html, an index.js and a style.css all in the same folder(master I believe). I've tried the following way to link the js and the css to the html:
<link rel="stylesheet" type="text/css" href="master/style.css">
<script src="master/index.js" type="text/javascript"></script>
However, it just doesn't seem to work. In the middle, the CSS seemed to link once, but then after that when I tried to link the JS too, the whole thing stopped working again. How do I fix this?
If all your files are in the same folder, I'm not sure you need to type folder's name. Try to remove "master/" in your two lines of code.
When you link stuff to your html file, the path is relative to that file.
So if style.css and index.js are in the same folder, you just link them by providing file names only.
If those file were in the folder above, you would link them by "../style.css" and "../index.js"
If those file were in the subfolder (in relation to index.html), you would link them by "subfolder/style.css" and "subfolder/index.js"
Hey guys i have a really strange issue, and that is that when i go the route http://localhost:5000/posts/edit/<%=idofblog%> all the CSS styling and Js code is not loaded and i have a very ugly looking web page i have no idea what is going on, all the other routes are working just fine.
All the CSS and Js folders are inside the public folder
app.use(express.static(path.join(__dirname,'public')));
this is my entire file structure
enter image description here
Inside the _layout folder i have a header.ejs file which has all the links to css like this:- <link rel="stylesheet" type="text/css" href="../css/register.css">
every route is working perfectly but as soon as i go to this route http://localhost:5000/posts/edit/<%=idofblog%> every CSS and JS code is gone and the images as well.
Inside the posts.js route i have this
router.get('/edit/:id',(req,res)=>{
res.render('edit');
});
And the href link in the ejs file is this
Edit
The page is loaded and everything like the input fields, textarea are there but there is no styling, i don't know what im doing wrong.
I am not sure but what I see, your problem might be that you are using relative paths to load your styles and scripts. You should use absolute, so for example to load css you need to do it this way(make sure to use path according to your project structure):
<link rel="stylesheet" type="text/css" href="public/css/register.css">
I have a javascript file that I would to add to discourse, but I am not sure how. Am I required to create a plugin to include a js file or can I include the file in the source code? Either way, I am not sure how to accomplish this.
If what you need is to embed, in every Discourse page, a tag linking to an external resource, you need to do the following:
Create a theme component and include it to all your themes
In your theme component, click "Edit CSS/HTML"
In the </head> section, enter your <script src="..."></script> code and click "Save"
In Discourse setting content_security_policy_script_src, add the full url of the script
The full doc is here.
I was able to achieve this by adding the following code <script async src="url-here" data-url="url-here"></script> Into the </head> section of /admin/customize/themes
Try using this :
<script src="**URL**"></script> under the head section.
The URL of the external script file.
Possible values:
An absolute URL - points to another web site (like src="http://www.example.com/example.js")
A relative URL - points to a file within a web site (like src="/scripts/example.js")
I'm trying to make a little website browsable both online and offline using only html, css and a little of jquery\javascript.
Hence I'm using all relative paths and everything works fine unless I came to the issue to load a custom menu in all my pages with a little smart jquery include.
However since my menu.html is loaded in different pages located in different subdirectories of the tree structure I am wondering what's the smartest way to write down the href links of the different voices in the menu.
I initially started using all absolute paths in the menu.html, but of course it just works only online or offline based on which root domain I use in the absolutes paths (either http://mywebsite.com/ or file:///D:myfolder/etc).
Of course also using the / at the beginning of a link works only online, since locally the / stands for the drive letter where the websites' folder is placed and it will work if and only if the website's folder is saved in the highest path like as D:/myWenbsite. I'd like to make something more adaptable regardless of the local path.
The best way in my opinion is to use relative URL's from the root. For example in your menu.html file when you reference jquery you can do the following:
/javascript/jquery.min.js
Adding the beginning '/' makes it so that the path always starts from the root of the domain no matter where your html is at in your directory.
If you used:
javascript/jquery.min.js
That means in whatever directory your menu.html file is in, a folder for javascript would also need to exist and that is not generally wanted.
Using the <base> command within a little script to change it solved my issue.
Here is an example:
<head>
<!-- Here a direct path is need to firstly load jquery -->
<script type = "text/javascript" src = "../include/js/jquery-1.10.2.min.js"></script>
<base id="host" href="" />
<script>
/* Where am I? */
here = window.location.href;
hereIndex = here.indexOf('temp-test');
/* make substring from root till temp-test/ */
newPathname = here.substring(0, hereIndex+10); //+10 to consdier also temp-test/
$("#host").attr("href", newPathname);
</script>
</head>
Don't know if there is a better way to do it.
Anyway even if the page renders correctly in the console log I still get errors on every relative path I have GET file:///D:/temp-test/core/image/temp1.jpg net::ERR_FILE_NOT_FOUND however for instance, this image is instead properly loaded. So what's up here with the base tag? It is kinda of not getting recognized but it works..
Further investigation is needed for me.
I'm using rails 2, and in one of the plugin I'm working on, I found this weird issue, I've TinyMce 4 customized text editor.
I've loaded the script at the beginning of the page, in the new form.
<script type="text/javascript" src="../tinymce/tinymce.min.js"></script>
TinyMce loads normally, and works completely fine.
In case of edit form the same script tag above doesn't work, I've move up 1 level to load it, I mean
<script type="text/javascript" src="../../tinymce/tinymce.min.js"></script>
Out of curiosity, what is going on here?
Folder Sturucture.
>>plugin_name
>>app
>>config
>>db
>>lib
>>public
>>images
>>javascripts
>>stylesheets
>>tinymce
I suspect your new page has a url like : /post/new whereas your edit page has a url like /post/1/edit
Because the edit URL has an extra / you need to go up an extra level in the relative path in your script tag.
Try changing the TinyMCE include to be an absolute path, not a relative one:
<script type="text/javascript" src="/tinymce/tinymce.min.js"></script>