I have a weird problem here, i have a page called index.php where in the head section i am including 5 Javascript files, but all of them are not working except the first js file. When i move my entire code to one file they start working but the moment i switch them back to from where they belong they stopped working and i have tried including the files before the body they don't work.
Any help
Thanks
Long story short: Save all of your files in UTF-8 format and try your page again. :)
I had the same exact problem. It was driving me mad, because I know this works! Many sites on the Internet include several JS files, and they were all working.
I finally figured out that my code editor (Notepad++) was set to save files in ANSI format. I changed the editor's setting to save files as UTF-8 and everything is working again.
I found this by opening the Chrome developer console on the broken page (Ctrl+Shift+I). I expanded the "<head>" section, and saw three "<script>" entries. I double-clicked on the link in the "src" attribute of the second "<script>" tag to see if I could at least view the broken JavaScript file from within the developer console. When the new page opened, it gave me a syntax error and showed me a bunch of Chinese characters. This was my clue that the file over on my web server had been saved in some format that my browser was not interpreting correctly.
Related
Trying to view the source code for github.your_company.com/stafftools/reports/dormant_users.js.
When I go to the link, it simply downloads a .csv file immediately, with no activity in the Chrome DevTools Network tab. I have tried disabling javascript, cURLing and so forth but nothing works.
Really surprised since from every SO post I've come across, they say it is impossible to hide the source code for .js files.
How do I protect javascript files?
Just thinking that this would be a really informative counter-example
I am new to web development. I use Brackets to do my development in. My webpage works using the live preview in Brackets but when I launch the page outside of Brackets, my JS doesn't load.
What I am asking is, is there a way to launch a webpage (HTML, CSS, JS) without creating a server for it all?
Look for the html file in your file system. Right click and open it in a browser of your choice.
Right now, it seems like clicking that file will open it in Brackets for you, however html files are able to be rendered by browsers when they read the html code.
Yeap, just put your HTML/CSS/JS in the same location — or different locations — and make sure you map to them properly.
From there, just double click your index.html — or whatever you named your html file — and it should popup in your browser.
I've read a lot of related answers but I still don't see the problem. I think MY problem is that I don't have a good grasp of the basics of HTML and potentially javascript. I'm talking about how they are stuck together and operate, not the particular language syntax. Perhaps somebody could give me the big picture explanation of what is going wrong here.
I'm using a simple WebBrowser control to navigate to a web page. This results in everything displaying correctly. Now, I'd like to save that HTML content locally on the machine and open it again later, then render it in another WebBrowser control. This has not worked so far. The page renders briefly but without images and effects, then I get an exception regarding scripts. So I decided to do a very simple test. I would get the HTML from the browser, then immediately read that text back into the browser.
After navigating to the page successfully, I get the HTML text as follows:
string html = myWebBrowser.DocumentText;
I then immediately set the DocumentText property to its original value.
myWebBrowser.DocumentText = html;
This gives me the same error and effect as if my other application was reading the saved HTML. So what is going on here? The browser initially shows all content successfully but then extracting and reloading the HTML text breaks it all. I must be missing a very obvious and basic concept here. Is it that the WebBrowser control's DocumentText property does not actually return the original HTML code, but rather a modified version? Or is it that setting that property modifies something? Is it neither? Thanks to anyone who can sort out my understanding of how all this works.
This is by design. HTML is not a fully inclusive file. The browser will parse the html and pull resources from other urls including scripts, images, styles, etc. If you save only the html and then open that file in a browser, many of the resources will not be found since they rely on the html loading them from their location relative to the html file. Once the file is on your computer, any relative link to a resource will be invalid resulting in the browser only showing the basic html and any resources that have been referenced by absolute paths and not relative paths.
So I am having an issue with the way my page appears on the server compared how it is working locally on my computer. Here is the code I am using: http://pastebin.com/pbDbNsNU -- There are no console errors, nor are there any issues with the code when displayed locally.
Once put on the server: http://devtherrd.com/thank-you/mortgage-lending.html -- you'll notice my footer's right hand side columns are completely gone. This only happens once put on server, but I am not sure why this could be happening since these are basic social media links and newsletter form. The same footer is working throughout the entire site, except for all my files within the /thank-you folder structure.
What recommendations do you for me. If there is missing information please let me know I can provide, I apologize in advance for my complete noob posting.
Thanks
Validate your code with:
https://validator.w3.org/nu/?doc=http%3A%2F%2Fdevtherrd.com%2Fthank-you%2Fmortgage-lending.html
There are HTML errors.
From what I have seen, the file which you uploaded on your server is incomplete.
It doesnot have the code to display that part. But the code you provided on pastebin works fine. So update the html file on the server. Your problem should be fixed.
I'm setting up Google Analytics for my Wordpress website. I'm using a theme called "Virtue." I want to track all the pages of my website, and from what I have read I need to paste my script at the end of the head tag.
My question is that in my public_html folder on my cPanel File Manager, I have three files that have the word "head" in them.
The directory is public_html/wp-content/themes/virtue/templates/head.php for the head.php file.
But there is also a header.php and a page-header.php file. Am I supposed to paste my code into each of these files, or just the head.php file?
I've read that Google Analytics takes a few hours to recognize the website, so I want to know if I'm pasting my code in the proper place. I really don't want to trouble shoot this for days on end because I'm at the point with my site where I would like to do Google AdWords.
Thank you very much for reading this post and responding as it is appreciated.
Plugins might slowdown the website. Just, Paste the code in public_html/wp-content/themes/virtue/templates/head.php
Just place the code in header.php.
And in case you do not want to edit any of file then you can use the below mentioned plugin to add the tracking code in the head section from wordpress backend itself :
https://wordpress.org/plugins/header-footer/
And if you also wanted to check whether the code is included or not that you can simply check the source view (Ctrl+U) of your website pages and search for Google analytics code.
The documentation of GA refers to the tag of the HTML document, and not a specific file.
If you're less tech-savvy, you can simply use one of the thousands of plugins that exist for this, for example :
https://wordpress.org/plugins/google-analytics-for-wordpress/
(I'm not affiliated, this is the first google search result).
You only need to put it in 1 file and it doesn't even matter which one as long as it's a file that gets included in every page.
I currently have no WP installation to check which one that is, but if you put it in the file that has the <head>-tag in it, you should be fine.