Creating an HTML link that will not be URL decoded - html

I need to create a link to a web page that contains the character # (%23). However, when the URL gets decoded (resulting in a URL containing #), the character is not recognized and the page is not displayed properly.
When I create a link as follows, the %23 just gets replaced with #. This may be the behaviour of the browser, but how can I stop it and reach the proper URL with the string still URL encoded? I would prefer to do it without JavaScript if it is possible.
click
Browser goes to: http://aWebsite.com/somePath/somePage #myParameter
I want to go to: http://aWebsite.com/somePath/somePage %23myParameter

It sounds like you need to encode it a second time. The "%" will become "%25" so you'll have:
click
Edit:
If you want the "#" to be sent to the server as part of the URL, then it's not going to work. The browser treats that as a bookmark so it is removed from the requested URL. Once the page is loaded, the browser will scroll to that bookmark.

You need to doube encode it:
http://example.com/somePath/somePage %2523myParameter
%25 will resolve in % in the final url

Related

Error when I refresh my index.html page in the browser : Your file was not foundIt may have been moved or deleted. ERR_FILE_NOT_FOUND?

Basically when i copy the full path of the website into the browser it shows me the contents just fine. However when I refresh the browser whilst editing the code to see how it looks I get the following error message and have to copy the full path again to see the results.
Your file was not foundIt may have been moved or deleted. ERR_FILE_NOT_FOUND?
A bit of explaining as to why you are getting %2520 is :
The common space character is encoded as %20. The % character is encoded as %25.
The way you get %2520 is when your url already has a %20 in it, and gets url-encoded again, which transforms the %20 to %2520
C:\Users\moh20\Desktop\Personal Portfolio\index.html <-- There is space between personal and portfolio.
If you provide a local file path only, the browser is expected to encode and protect all characters.
So that space which is treated as %20 is again encoded (only % sign needs encoding here) to %2520.
Solution :
Pass the url along with proper protocol like file://
You can do that in two ways :
1. Right-click on your HTML file and select to open it in a browser to view it.
2. Manually type the protocol along with full file path.(or you can just replace %2520 to %20 in the second url after refreshing).

How to Prevent Browser Control from URLDecoding an Embedded URL Link

Please forgive my lack of knowledge surrounding HTML
I am trying to generate a static HTML page which is rendered in an embedded HTML Browser component in a 3rd party application.
In the HTML Body I have a URL Link embedded within the page.
Access Application
Note that the above URL is "URLEncoded". Specifically, the query string after "encrypt=" is encrypted, and then URLEncoded.
Problem
The HTML browser component embedded in the 3rd party application renders the HTML and all appears fine, EXCEPT that it Decodes the URL String.
This results in a hyperlink with the following URI;
https://mydomain.com.au/Web/Default.ashx?encrypt=x+NWTAVMqprD+ZyFtf1tfBVfIfhqKJ3JCjMmiXiSJSUl6n4FzCuW8mwQfpNskdQEvqU7QiWMdR+bu9y6+iO8eh41XwGJX9l5iCYZunTamhGdkkiR9CqVCrkStu+zAlhqcJYG6M0zztcActpm6iSn99gXDlw8z+Hs8Q88N9fZyXdYpxspgl+AoGZe7hR3zOulJb1YhabyBbf+kfI0dq1YQpHn3SWig8HuWvBANXPrPHDqAOsnT1DtJQ==
Note the now existance of characters such as "+" and "=" which causes the failure to load the application which is the target of the URL.
Is there any way to prevent a browser (browser control?) from decoding this URL string and maintaining its integrity?
I am thinking off the top of my head, and I don't really understand the purpose of this suggestion but will defining a "type" attribute on the Link such as
<a type="application/x-www-form-urlencoded" href="xxx.com/ddddd" class="Action">Access Application</a>
have any effect?
How else can I prevent the browser control from decoding this URL?
Meta Tags in the < head > ???
Thanks in Advance!
Kind Regards
Aaron
We had to escape the % symbol.
For example: changing %2B in the link to %252B (%25 being the escape code for a % symbol). Likewise changing %3D to %253D had the same effect and prevent the client application rendering %3D to a = sign.
We couldn't stop the client application from 'decoding' the URL entirely but at least now it decoded to the correct URL value

Why is IE10 removing URL hash marks on external redirect links

I have a basic link:
Free Pie Here
but when I click on it, I'm redirected to https://pieworld.com/apple
Everything after the hash mark, as well as the hash, are not included. This is only happening in IE10. I've tested without the target="_blank" as well, but the link still breaks at the hash.
Can't seem to find any documentation on this. The closest I've come to is this SO question, but it doesn't help.
Some background info that might help:
This is a .Net site
I'm redirecting from a http: to a https: site.
According to the RFC3986 https://www.rfc-editor.org/rfc/rfc3986 it is not OK to use this format. You should remove the trailing slash. If you have a trailing slash, it points to a directory within the server. Without it, you point to a document and with the hashmark you are allowed to point to a segment of the document. See example here.
A hash character is used for bookmarks in an URL. To use a hash character as part of the URL itself, you need to URL encode it using %23:
Free Pie Here
Why do you have a trailing slash after the hash?
Try https://pieworld.com/apple/#1
That would be more standard. I've never heard of anyone putting trailing slashes after hash links.
I Think, as the other folks suggested, that the website that you are trying to navigate to may interpret the /#1 as a folder/page inside the parent-page/document. Try removing the forward-slash before the #1 or look inside the html for the header's id/name tag so you can link it directly.
May also be a bug in IE10.
-Phantom
Any URL that contains a # character is a fragment URL. The portion of the URL to the left of the # identifies a resource that can be downloaded by a browser and the portion on the right, known as the fragment identifier, specifies a location within the resource.
http://www.httpwatch.com/features.htm#print
In HTML documents, the browser looks for an element with id attribute matching the fragment. For example, in the URL shown above the browser finds a matching tag in the Printing Support heading:
<h3 id="print">Printing Support</h3>
and scrolls the page to display that section.
I am not sure if the slash after the hash is supported. If you didn't mean to use it as a fragmented url, you should remove the hash or replace it.
The syntax of the Location header field has been changed to allow all URI references, including relative references and fragments,
along with some clarifications as to when use of fragments would not be appropriate. (Section 7.1.2)
for more information check this thorough post.
Hash removed from URL when back button clicked IE9 , IE10 IE11
In IE10 browser, first time on clicking the HREF link, then it comes to the correct below url: http://www.example.com/yy/zz/ff/paul.html#20007_14
If back button is clicked from the IE10 browser and again clicked the HREF link , then it comes to the below url: http://www.example.com/yy/zz/ff/paul.html
Solution :
Please change your url with https
It works for mine

Unwanted characters being added to url in HTML

I'm trying to include a simple hyperlink in a website:
...Engineers (IEEE) projects:
So that it ends up looking like "...Engineers (IEEE) projects:" with "IEEE" being the hyperlink.
When I click on copy link address and paste the address, instead of getting
http://www.ieee.ucla.edu/
I get
http://www.ieee.ucla.edu/%C3%A2%E2%82%AC%C5%BD
and when I click on the link, it takes me to a 404 page.
Check the link. These special character are added automatically by browser (URL Encoding).
Url Encoding
Use this code and it will work::
IEEE
The proper format to add hyperlink to a html is as follow
(texts to be hyperlink)
and for better understanding go through this link http://www.w3schools.com/html/html_links.asp
%C3%A2%E2%82%AC%C5%BD represents „ which is when you get when a unicode „ is being parsed as Windows-1252 data.
Use straight quotes to delimit attribute values in your real code. You are doing this in the code you have included in the question, but that won't have the effect you are seeing. Presumably your codes are being transformed at some point in your real code.
Add appropriate HTTP headers and <meta> data to tell the browser what encoding your file is really using

prevent browser from evaluating %2F

I have a php script which generates a bunch of links like so
link
but when I hover over this link or click on it, it really goes to
http://localhost/explorer/index.php?repository_id=default&folder=/mypath/inner/inner2
How do I prevent this behavior and force it to go to http://localhost/explorer/index.php?repository_id=default&folder=%2Fmypath%2Finner%2Finner2
The tool which receives this input needs to have %2F inside of the /
The hover display is often unescaped for ease of use. If you inspect the page source it should still be uri escaped.
When you use the link the GET param will still be uri escaped and get to your php script intact.
You need to encode the URL string you are using. http://php.net/manual/en/function.urlencode.php
Or manually Replace %2 with %252F (% encoded + 2F)