Notepad++ doesn't open my html file but the google home page - javascript

I'm trying to learn html and javascript but I'm having problems opening html files with notepad++.
I downloaded notepad++ and I created a simple html file.
<html>
<body>
Hello world!
</body>
</html>
I uncommented the option to run a file with chrome in the shortcut.xml file.
Finally, I added the chrome link in the notepad++ folder.
When I run the file with chrome, the browser opens the google home page instead of the file.
Whereas, if I write the code in notepad, and I open the file with chrome, the browser opens it up correctly.
I've not set a cloud path yet. Do I have to set one? If yes, which one?

The menu item should say "Launch in Firefox" - corresponding to the name= attribute in the settings file, the fact it isn't means that your likely editing the wrong settings file.
If you have set Settings -> Preferences -> Cloud to a directory then that's where the correct XML file will be, otherwise look in both %APPDATA%\Roaming\Notepad++ & the install dir for other copies of the file.
> what are the best editors for html and javascript
Subjective, but take a look # https://code.visualstudio.com/docs/languages/html

Place the path into quotation marks
<Command name="Edge" Ctrl="no" Alt="no" Shift="no" Key="0">"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "$(FULL_CURRENT_PATH)</Command>

You shouldn't try to run it from notepad++ itself. Instead, Just Right Click your file from the file explorer and Open with Google Chrome. It should open your file that way.

Related

Script tag source defaults to URL over path

I'm trying to make a chat application using socket.io and Node.JS. In my html file called index.html, I am trying to use a script tag to point to a script file called bundle.js that contains a browserified set of variables and functions.
The problem is, despite referencing the proper path in my src attribute, the tag seems to include a bundle.js within my localhost:3000.
Oddly enough, when viewing this bundle.js with developer tools, the content seems to be identical to that of my index.html file. This creates a syntax error as the JavaScript file contains html syntax from my html file. Any ideas why this might be?
<script src="bundle.js" type="text/javascript"></script>
This is how the script tag appears in my html file.
This is a link to a screenshot of my developer tools (New here so not enough rep to post the actual pic)
As we can see bundle.js is open in developer tools is Html code, not js that's why error is shown in first line, or there is something wrong in webpack configuration.

Can i open the cookies file and see what's in that file?

I found a cookies file in the location "C:\Users\Agnivesh\AppData\Local\Google\Chrome\User Data\Default".
I'm a little curious about the data in it.
I only see unformatted text when I opened the file in notepad.
Is there a way to open and see the contents of that file?
The most straight forward way to examine them is to open your developer window as you browse like below
Click F12-> then follow the tabs
Checked with Microsoft Edge: It's an sqlite file, which can be opened easily. e.g this link: https://inloop.github.io/sqlite-viewer/
Enjoy!
This will allow you to check out all of your cookies, not just the ones on specific websites.
(Found this out by trying to open with vs code, on the top of the file "SQLite format 3")

Run javascript file from the workspace in chrome developer tools

Is it possible to run a newly created JavaScript file in a local workspace in the chrome developer tools console?
The workflow I'm trying to achieve is the one shown in this image:
I want to be able to create a new file in my workspace, run (or require or whatever) the file and be able to use it's functions and variables in the chrome developer console.
If I'm correct, this means running the script within the context of the webpage and adding the methods and variables to the window object?
Is their a way this can be done?
I could not find an automatic way to add a local file into the DOM context. The best solution I found so far:
Open your local workspace and the right file
Press CTRL + a (Select all)
Press CTRL + SHIFT + e (alternative: Right click with the mouse on the selected text and click on "Evaluate in Console")
Well, this is not much better than copy&paste but spares a few key presses/mouse clicks.
You can create a plain html file like this with your javascript file in the script tag.
Then you should be able to get all your methods in the developer console.
You can define a method in your page to dynamically add javascript to the page and then call it from the console.
For example if you had a method like this:
function loadJs(filename) {
var tag=document.createElement('script');
tag.setAttribute("type","text/javascript");
tag.setAttribute("src", filename);
document.getElementsByTagName("head")[0].appendChild(tag);
}
then you can use that method from the console to load your javascript files.
As an example:
Step 1: we create one folder "TestJS_folder" and it contains two files.
First file is index.html
Second file is test.js file.
Content of html file can be :
<html>
<head>
<title>Test JS in Chrome</title>
</head>
<body>
<script src="test.js"></script>
</body>
</html>
Step 2: Now you can import/open this test.js file in VSCode or any editor. And you can code the js file from IDE and click on index.html , it will open the html file on browser and you can go to Inspect-> console to check the logs based on your use case.

jQuery file not being retrieved from server

For some reason my html file's request for my jquery.js file fails, however when I enter that exact url into a new tab in the browser, I get the exact jquery.js file I am trying to get when the website loads.
My code is as such:
<script src="js/jquery.js"></script>
and my website is here. If you append jquery.js to the root, you will see the exact file.
Can anyone explain why the file isn't properly retrieved when the website loads?
Any help is greatly appreciated.
At the beginning of your HTML file is this:
<!DOCTYPE html>
<html manifest="appcache.appcache">
The appcache.appcache refers to the file appcache.appcache whose content is:
CACHE MANIFEST
# V1.65 1-18-2013 10:15 PM
# cache
index.html
about.html
services.html
contact.html
css/signika.css
css/mq.css
css/index.css
css/about.css
css/services.css
css/contact.css
assets/signika_400.woff
assets/signika_600.woff
js/html5.js
js/index.js
js/mq.js
js/services.js
mail.php
images/chicken.png
images/salad.png
images/soup.png
images/steak.png
images/wontons.png
As you can see jQuery.js is not there. I suggest you to add js/jQuery.js into a new line and try again.
I figured this out by:
Running the Fiddler software side by side with Chrome (on Windows).
Loading your website in Chrome with Developer Tools (Ctrl+Shift+I on Windows, Command ⌘+Option ⌥+I on Mac), then go to the Network tab.
Then I see that Chrome loads appcache.appcache from the second time onwards and there's an error when loading jQuery.js.
The manifest attribute refers to the HTML5 cache manifest file.
Tutorial:
http://www.html5rocks.com/en/tutorials/appcache/beginner/
More references:
http://caniuse.com/#search=manifest (browser compatibility)
http://en.wikipedia.org/wiki/Cache_manifest_in_HTML5 (wiki)
https://www.google.com/search?q=html5+manifest
It's probable that the HTML file containing the script header in question is not in the "root" but perhaps in the same JS folder or somewhere else.
So technically this should work:
<script src="/js/jquery.js"></script>
Just keep in mind that this path is relative.

Edit external JavaScript file after breakpoint is hit

In the VS2010 IDE when a breakpoint (or an error) is hit, it opens a read-only [dynamic] version of the external JavaScript file I referenced. My workflow would be vastly improved if I could immediately edit this file, and refresh the browser. That is as opposed to digging up the original JS file opening it, finding the correct line and editing there.
I only know that this is possible because I was able to do this on my old work computer configuration, but for the life of me I can't duplicate it at home.
Has anyone made this work? Perhaps an extension? or maybe it has to with the way the files are referenced, or my basehref tag, or url rewriting.
This happens when the base href specifies a domain other than localhost. My issue was that to enable a local environment for Facebook JS, I need my domain in the url. So I set up my host file to remap localhost.mydomain.com to localhost.
When the Visual Studio IDE encounters a file reference which is something other than localhost, it does not attempt to grab the local file since it assumes (correctly in most cases) that it is being served from another site. In these cases it loads a file as [dynamic] and readonly.
Here is the test case:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="http://localhost.mydomain.com/virtual-directory/" />
<script type="text/javascript" src="test.js"></script>
</head>
<body>
</html>
Any breakpoint within test.js will result in opening a readonly dynamic file.
how are you referencing your files? whenever a script block is written inside the html or is dynamically inserted the debugger will open the instance of the page where the code stops. If you reference the script using tags vs should open the original script file (at least that's what it does on my machine). could you upload an example of your current structure?

Categories

Resources