How to make working path in HTML? - html

So, currently I'm making a website. It's an assignment. And when I tried to open it on different computer, it didn't work.
So, for example: "a href="file:///E:/assignment/main page/index.html#"
It did work on my computer, but it won't work on another. I need it to work at any computer.

There are two halves to your question:
How do I make my website accessible anywhere?
You need a web server, or you need to use a hosting company. GoDaddy, 1and1, HostGator, and other hosting companies have computers (web servers) that are configured to show their webpages to anyone in the world. They cost around $10 per month, and you end up with the ability to create links such as http://example.com/myproject/index.html
It's possible that your professor will let you put your web pages on one of his drives that are accessible anywhere on campus. Otherwise, a flash drive can do in a pinch. Put the files onto a flash drive and then bring the flash drive to class.
Is there a better way to write links?
Most websites use relative URLs in their links. For example, Stack Overflow, instead of writing every link as http://stackoverflow.com/whatever, will usually use a relative URL instead: /whatever.
There are a few simple rules that your browser follows when turning an href tag into a web address (in this example, we're starting from this page: http://stackoverflow.com/questions/15078748/how-to-make-working-path-in-html#15078792)
If the link starts with http:// (or anything else that comes before
a ://), then your browser will take you exactly there. For example:
http://stackoverflow.com takes you to the Stack Overflow home page.
If the link starts with /, then the browser will take you out of
any subfolders before executing the rest of the link. For example:
/election will take you here: http://stackoverflow.com/election
If the link starts with ../, then it will send you exactly one folder
up. This can be done multiple times. For example. ../ will send you
here: http://stackoverflow.com/questions/ .
If the link starts with a
question mark, ampersand, or hash tag, (?, &, #) then it will usually append
this to whatever page you are currently on. #example would take you
to
http://stackoverflow.com/questions/15078748/how-to-make-working-path-in-html#example
.
Finally, the browser will keep you in your current folder, then
send you to that link, for example: example will send you here:
http://stackoverflow.com/questions/15078748/example

You must use relative paths not absolute paths.

In simple words, you have to write:
...
to link to index.html a page which is in the same directory as your file index.html;
examples:
./my_page.html
use the "./" for linking pages in the same directory;
if the source and dest pages are in different folders, you shall use:
../my_page.html
or
./folder_path/my_page.html
according to the relative paths of the pages.

Related

Multiple kentico sites, direct url to CSS for one site is requiring a login

I have a kentico install with multiple sites, all 'should' be set up the same but having a weird issue with the 3rd site i just launched. Any sort of file (image, script, or css) won't load by its relative path, and if i try to open the url i am presented with a kentico login screen.
The truly weird part is if i put the same url path but put one of the other sites domains in front of it, the image loads fine.
newsite.com/imageURL <- wont load
othersite.com/imageURL <- loads
otheroldsite.com/imageURL <- loads
hopefully that makes sense, i've never seen anything like this before.
Start with CSS first, make sure you've enabled the css for your new site:
CSS stylesheets\YourCSSName\Sites
For the media library you must have permissions
Media libraries\YourMediaLibraryName\Security
Make sure that 'See library Content' is set for All Users
But scripts usually in ~/CMSScripts/Custom/ so any site in you case should be able to access them. If your script is there and you can't load it - it's not Kentico permission issue.

Use environment variable in link in email

I want to generate links that can be pasted in emails so I can show people folders in their directory structure such as where to edit their email signature manually.
I'm trying to put a link to the folder in an email but make it generic enough that when they forward it, everyone who opens it will get the link into their own directory structure properly so I need to use environment variables.
I type the text I want the link to say then highlight and CTRL-K then put %CSIDL_APPDATA%\Microsoft\Signatures\ in the link but Outlook changes my % symbols to %25's. I'd ask how to escape a % but it shouldn't be escaped I don't think since it's actually part of a link.
Environment variable list FYI:http://technet.microsoft.com/en-us/library/dd560744(v=ws.10).aspx
Simple answer, you can't. When you're linking like that, the current directory looks like root / to the html. So you could look at a subfolder of current directory (which you aren't guaranteed to know since it could be different on different OS's or even per user configuration) but that won't really help you.
This project will let you edit the actual HTML of your email by adding an Advanced tab but even with full control of the HTML, it can't be done. "It would open up a security hole the size of Denver."
Here's a lot of quality info on Relative Addressing which is what you're trying to do.
this is because outlook parse your input as HTML link.
I did not test it but you should give a try to this file://%CSIDL_APPDATA%/Microsoft/Signatures/
See this answer too : ways to make an html link open a folder

How do I Prevent Httrack From Downloading the Same File Again?

I am using httrack to download this website:
http://4minutearticles.com/
However, the problem is that the author has link back to the main page on every page of his website
For example http://4minutearticles.com/ext/
The Parent Directory Link Redirect to the main page
and the software start downloading again
How do I prevent this loop from happening?
Read the answer to the question on the link provided below:
"I have duplicate files!What's going on?"
Link: http://www.httrack.com/html/faq.html#Q1b11
Also have a look at the "Filters:Advanced" on following link:
http://www.httrack.com/html/filters.html
It may help you on your issue.
You can use filters to stop HTTRACK from downloading same files or folders. You can do this by clicking the "Set options" button in front of the "Preferences and Mirror options" label, then opening the "Scan Rules" tab and then the "Exclude links" button to set the rules as you want.
This is generally the case for top indexes (index.html and
index-2.html).
This is a common issue, but that can not be easily avoided!
For example, http://www.foobar.com/ and
http://www.foobar.com/index.html might be the same pages. But if links
in the website refers both to http://www.foobar.com/ and
http://www.foobar.com/index.html, these two pages will be caught. And
because http://www.foobar.com/ must have a name, as you may want to
browse the website locally (the / would give a directory listing, NOT
the index itself!), HTTrack must find one. Therefore, two index.html
will be produced, one with the -2 to show that the file had to be
renamed.
It might be a good idea to consider that http://www.foobar.com/ and
http://www.foobar.com/index.html are the same links, to avoid
duplicate files, isn't it? NO, because the top index (/) can refer to
ANY filename, and if index.html is generally the default name,
index.htm can be choosen, or index.php3, mydog.jpg, or anything you
may imagine. (some webmasters are really crazy)
Note: In some rare cases, duplicate data files can be found when the
website redirect to another file. This issue should be rare, and might
be avoided using filters.
See also: Updating a project

Loading resources from html5 filesystem api

I am writing a chrome extension that dynamically writes some html pages and their resources to the file system. I have most things working but I just noticed that when I try to open one of the pages by navigating to the filesystem:chrome-extension://... url that I obtain via the fileentry.getURL() method, the page opens, but chrome does not fetch any of the associated resources: stylesheets, images etc. Any ideas why this might be? Are there some security flags I need to get this working? I am i going about this all wrong?
(One thing that may be relevant is that the resources are identified by relative urls. But I know they are correct relative to the file because if i manually resolve them and browse to the URLs I can fetch them.)
The page you include that uses the relative URLs doesn't understand the HTML5 filesystem's mapping. If you change the URLs to point to what the fileentry.getURL() calls give you, then this should work.
There's currently a bug that allows relative URLs in resources to be used like you're trying to do: http://crbug.com/89271

How to link a relative html file in the scenario where user can call the files from the browser by adding a / at the end

(Sorry I am not able to frame question correctly.)
Following is the scenario.
I have 2 Html files.
File1.Html has
Click Me
File2.Html has
Click Me
Now when I open the file1.html in browser by typing following in browser.
http://Localhost/File1.html
The file1.html with a link is shown and when clicked it goes to
http://Localhost/File2.html
BUT
If I open the file1.html in browser by typing following in browser(note the / at the end).
http://Localhost/File1.html/
The file1.html with a link is shown and when clicked it goes to
http://Localhost/File1.html/File2.html
I know this is not a right way to do in browser but you cant stop user doing so.
The above example I have used just to simplify the issue. My real production issue issue is while using the MVC url are actually routed. So a user can legally use http://example.com/Employee Or http://example.com/Employee/ and due to this my jqGrid is not working.
Please guide me for a workaround.
UPDATE:
This works ok in IExplorer : wierd.
You want a link relative to the root. The following:
Click Me
(note the '/' at the start of the href) will link to http://Localhost/File1.html wherever the page containing the link is (so long as it's on the same host).
not relative to root i need it relative to parent
That's not possible. If you are using routed URIs there can be all sorts of /path/segments following the base name. The browser has no way of knowing what the real ‘parent’ is.
The usual solution is to use root-relative URIs as suggested by Joe. If you need to allow your application to be mounted at a configurable prefix under the root, that prefix will need to be copied out into the link.
Your question reminds me of a technique for search friendly URLs, implemented in PHP.
Things like:
http://localhost/index.php/2009/09/
It was described on Sitepoint.com The idea was that index.php could retrieve the trailing part of the URL from the web server and decide what to do with it. Including whether to deal with a final / or not.
It won't be relevant to html files (which could not, after all, retrieve the trailing part of a URL) but it might provide further ideas.