i have a site in cakephp version 1.2.1.8004, on the admin side scripts_for_layout is used to generate the css and js hash.
Every time on page load it generates a different hash.css file and hash.js file to call the css and js file, so it cannot call the correct css and js file which is present.
i checked on other site where the same hash is generated everytime.
This was due to incorrect permissions given to css and js folders. since it could not access the folders it would try to create a new file with new hash everytime.
Related
I am new to moodle. I have a requirement to run a js every time a user clicks on a download file or watch a video.
I don't know where or how to add these files.
I have seen how $page is used.
But is there a global location, like the, master page in .net?
You can create a new js file in your Moodle theme folder.
Path to create new js file
theme->your_theme_folder->javascript-> create new js file here.
Now include your js file in your_theme_folder->config.php like below code
$THEME->javascripts_footer = array('modernizr');
Then you have to purge all cache in Moodle by going to
Site Administration->Development->Purge all caches
That's it your js code will work on all page
I have an Apache web server where I must display some graphs and I must be able to do it offline. I have a couple of js libraries I must use in order to render the graphs and when I load my index.php page, it gives me GET http:d3.js/ net::ERR_NAME_NOT_RESOLVED, but the file is in the right folder and I've copied and pasted the code in index.php in a test file and when I open it, it works just fine.
The html for the graphs is being generated using the MPLD3 function of fig_to_html, this function generates an html string, that I append to my index.php, the path to the js libraries is also specified in that function:
mpld3.fig_to_html(fig, mpld3_url='file:///home/pi/webpage/mpld3.js, d3_url='file:///home/pi/webpage/d3.js')
Does not seem a valid file url:
http:d3.js/
Try "d3.js" or "/[path-on-site]/d3.js".
I am trying to achieve the below in ASP.NET MVC3 web application which uses razor.
1) In my Index.cshtml file, I have the below reference.
<script src="/MySite/Scripts/Main.js"></script>
2) I load my home page for the first time and a http request is made to fetch this file which returns 200.
3) Then, I made some changes to the Main.js and saved it.
4) Now I just reload the home page (please note that I am not refreshing the page) by going to the address bar and typing the home page url and pressing enter. At this point, I want the browser to fetch the updated Main.js file by making a http request again.
How can I achieve this? I don't want to use System.Web.Optimization bundling way. I knew that we can achieve this by changing the URL (appending version or some random number) everytime the file changes.
But the challenge here is the URL is hardcoded in my Index.cshtml file. Everytime when there is a change in Main.js file, how can I change that hardcoded URL in the Index.cshtml file?
Thanks,
Sathya.
What I was trying to achieve is to invalidate browser cache as soon as my application javascript file (which already got cached in the browser) gets modified at the physical location. I understood that this is simply not achievable as no browsers are providing that support currently. To get around this below are the only two ways:
1)Use MVC bundling
2)Everytime the file is modified, modify the URL by just appending the version or any random number to the URL through querystring. This method is explained in the following URL - force browsers to get latest js and css files in asp.net application
But the disadvantage with the 2nd method is, if there are any external applications referring to your application's javascript file, the browser cache will still not be invalidated without refreshing the external application in browser.
Just add a timestamp as a querystring parameter:
var timestamp = System.DateTime.Now.ToString("yyyyMMddHHmmssfff");
<script src="/MySite/Scripts/Main.js?TimeStamp=#timestamp"></script>
Note: Only update TimeStamp parameter value, when the file is updated/modified.
It's not possible without either using bundling (which internally handles version) or manually appending version. You can create a single file bundle as well if you want.
I have event coded to show the event on each page of the website. Is there a way to code it so that when you need to update it, you can do it once and it will show on each page? (vs having to update HTML text on each page).
Yes, create a external JavaScript(.js) file and include it on the each page. e.g
<script src="scriptfile.js"></script>
Whenever you want to update/change, just update the js file.
Definitely. You can set up a local server and then make .php files having html code in them. You can then include these .php files in your different html files as and when required. But for all this to work, local server configuration is required(like Apache and MySQL).
I'm trying to retrieve the ID of an employee and show them in my details page by retrieving the Employee ID from the URL using Page Mapping in ASP.NET:
RouteTable.Routes.MapPageRoute("", "employee/{id}", "~/details.aspx");
Such that the URL will be:
www.myexamplewebsite.com/employee/7937822353
The problem is, the Javascript files don't get loaded and the console is full of my javascript errors. I get a 404 error in my JS scrips as well. The page can't find any JS file when mapped. Why is this happening when I map the URL? This does not happen if the URL is www.myexamplewebsite.com/7937822353.
What am I doing wrong?
EDIT:
This is how my JS files are referenced:
<script src="js/chatbar/rightside.js"> </script>
The script is relative, and it's from the perspective of the client side URL. So when you change the page route to have the page appear to be served from a /employee subdirectory, the correct relative path to your scripts changes. So it's looking for the scripts at /employee/js/charbar/rightside.js. You could change those relative paths (to something like ../js/chartbar/rightside.js), but you might run into a problem later if you change the routing again.
So instead, it's best to make the reference application root relative.
<script src='<%= ResolveClientUrl("~/js/chatbar/rightside.js")%>'></script>