Rectangle 27 10

Easier to read and harder to screw up if you parse and set fragment & query to nil instead of rebuilding the URL.

parsed = URI::parse("http://www.domain.extension/folder?schnoo=schnok&foo=bar#frag")
parsed.fragment = parsed.query = nil
parsed.to_s

# => "http://www.domain.extension/folder"

Removing a part of a URL with Ruby - Stack Overflow

ruby-on-rails ruby url query-string
Rectangle 27 40

As others have mentioned, replaceState in HTML5 can be used to remove the URL fragment.

// remove fragment as much as it can go without adding an entry in browser history:
window.location.replace("#");

// slice off the remaining '#' in HTML5:    
if (typeof window.history.replaceState == 'function') {
  history.replaceState({}, '', window.location.href.slice(0, -1));
}

Solid. I appreciate the detection of ability to remove the #, but backwards compatible.

html - Remove fragment in URL with JavaScript w/out causing page reloa...

javascript html url fragment-identifier
Rectangle 27 4

Quotes are not allowed in the fragment part of a URL, so you have to percent-encode it with %22:

https://goout.net/cs/jine-akce/3-2-1-jedem-impro-talk-show-s-cestovatelem-danem-pribanem/qmnub/#%22T%22:%222017-03-15T20:00:00%22

url encoding - Invalid quotes in URL - Stack Overflow

url url-encoding w3c-validation double-quotes
Rectangle 27 6

The ampersand (&) has special meaning in a URL, being used to separate elements within Query String and Fragment parts. This usage is forbidden by default because it's typical for hackers to probe around like this, trying to discover exploits.

To avoid this you need to use URL encoding on the path, so the ampersand is encoded to %26, making the final URL:

http://localhost:4566/PropertyMap/project/ackruti-gardenia-dahisar-%26-beyond-mumbai

Since you do not specify where the URL is constructed I cannot help you with how to encode it properly - implementation differs per language.

Not that I'm disagreeing with you, but wouldn't the query actually start after a question mark ?? If an ampersand appears before the question mark, does it still denote the query string? For example: new Uri(@"http://localhost:4566/PropertyMap/project/ackruti-gardenia-dahisar-&-beyond-mumbai").Query is blank, but the LocalPath still shows the full path. (the reported exceptions are probably how the request validation operates as a security measure) Only once you throw in a question mark in there does it start separating out the content.

c# - Error : potentially dangerous Request. how can able to allow the ...

c# asp.net
Rectangle 27 4

The fragment part of the URL is used to enable navigation history (back and forward buttons) on AJAX-enabled websites. If you want to "trap" clicks on links, since you're using jQuery anyway, you could just do that:

$('a').click(function()
{
   var item = $(this);
   var url = item.attr('href');
   // your logic here
});

If you use fragments (window.location.hash) in constellation with AJAX, note that IE6 submits the fragment part of the url in AJAX requests which can lead to very hard-to-debug bugs, so be aware of that.

javascript - How to monitor the changes in the url (Fragment identifie...

javascript jquery html url uri-fragment
Rectangle 27 6

It is not converted as having the query part of the URL after the fragment is not valid.

RFC 3986 defines a URI as composed of the following parts:

foo://example.com:8042/over/there?name=ferret#nose
     \_/   \______________/\_________/ \_________/ \__/
      |           |            |            |        |
   scheme     authority       path        query   fragment
URL1: http://www.example.com/?query=#ajax_call
URL2: http://www.example.com/#ajax_call?query=

will not. If we look at URL2, IE actually handles the URL properly by detecting the fragment as #ajax_call?query= without a query. Fragment is always last and are never sent to the server.

IE will properly encode the query component of URL1 as it will detect it as a query.

As for decoding in PHP, %D2 and similar is automatically decoded in the $_GET['query'] variable. The reason why the $_GET variable was not properly populated was because in URL2, there is no query according to the standard.

Also, one last thing... when doing '' == $_GET['query'], this will only be true if your PHP script itself is encoded in UTF-8. Your text editor should be able to tell you the encoding of your file.

Yes, indeed. Thank you for such a good reply. But it is a common practice to use fragment for ajax addresses. And it is a source of a problem, not a solution.

@topright: It is the solution. I'm not saying to drop the fragment all together, I'm saying that your fragment should always be last. Rewrite your links to respect that. PHP does not handle the query after the fragment as it does not expect it to the there (it's illegal according to RFC3986). IE does not even bother to try encoding it as it is expecting a fragment (which are limited to ASCII characters only).

#ajax_call?query=
ajax_call?query=

is not send to the server

anything you put after # in the URL is never send to the server

Don't believe me? Try it out... echo $_SERVER['REQUEST_URI']; will give you exactly the request as seen by Apache. You'll quickly notice the fragment is missing. Also check your logs... There will be no fragment.

@topright: See, now the question is clear, and I'm willing to bet that the problem lies in your JavaScript Fragment-To-Query code.... Can you post that bit of code?

PHP UTF-encoded URL-string - Stack Overflow

php url utf-8 utf8-decode
Rectangle 27 8

That site makes use of the "fragment" part of a url: the stuff after the "#". This is not sent to the server by the browser as part of the GET request, but can be used to store page state. So yes you can change the fragment without causing a page refresh or reload. When the page loads, your javascript reads this fragment and updates the page content appropriately, fetching data from the server via ajax requests as required. To read the fragment in js:

var fragment = location.hash;

but note that this value will include the "#" character at the beginning. To set the fragment:

location.hash = "your_state_data";

ajax - jquery: change the URL address without redirecting? - Stack Ove...

jquery ajax redirect location
Rectangle 27 8

That site makes use of the "fragment" part of a url: the stuff after the "#". This is not sent to the server by the browser as part of the GET request, but can be used to store page state. So yes you can change the fragment without causing a page refresh or reload. When the page loads, your javascript reads this fragment and updates the page content appropriately, fetching data from the server via ajax requests as required. To read the fragment in js:

var fragment = location.hash;

but note that this value will include the "#" character at the beginning. To set the fragment:

location.hash = "your_state_data";

ajax - jquery: change the URL address without redirecting? - Stack Ove...

jquery ajax redirect location
Rectangle 27 8

That site makes use of the "fragment" part of a url: the stuff after the "#". This is not sent to the server by the browser as part of the GET request, but can be used to store page state. So yes you can change the fragment without causing a page refresh or reload. When the page loads, your javascript reads this fragment and updates the page content appropriately, fetching data from the server via ajax requests as required. To read the fragment in js:

var fragment = location.hash;

but note that this value will include the "#" character at the beginning. To set the fragment:

location.hash = "your_state_data";

ajax - jquery: change the URL address without redirecting? - Stack Ove...

jquery ajax redirect location
Rectangle 27 8

That site makes use of the "fragment" part of a url: the stuff after the "#". This is not sent to the server by the browser as part of the GET request, but can be used to store page state. So yes you can change the fragment without causing a page refresh or reload. When the page loads, your javascript reads this fragment and updates the page content appropriately, fetching data from the server via ajax requests as required. To read the fragment in js:

var fragment = location.hash;

but note that this value will include the "#" character at the beginning. To set the fragment:

location.hash = "your_state_data";

ajax - jquery: change the URL address without redirecting? - Stack Ove...

jquery ajax redirect location
Rectangle 27 179

The main problem is that the browser won't even send a request with a fragment part. The fragment part is resolved right there in the browser. So it's reachable through JavaScript.

Anyway, you could parse a URL into bits, including the fragment part, using parse_url(), but it's obviously not your case.

http - Can I read the hash portion of the URL on my server-side applic...

http url web language-agnostic uri-fragment
Rectangle 27 179

The main problem is that the browser won't even send a request with a fragment part. The fragment part is resolved right there in the browser. So it's reachable through JavaScript.

Anyway, you could parse a URL into bits, including the fragment part, using parse_url(), but it's obviously not your case.

http - Can I read the hash portion of the URL on my server-side applic...

http url web language-agnostic uri-fragment
Rectangle 27 2

Everything after the # is stripped out - the browser does not send fragment part of the URL to the server.

If you want those parameters to be treated as part of the query string they must be before the #

Yep. IE. the params are not stripped out, but they are interpreted as being part of the anchor. Your computer sees the anchor as an_anchor?p1=1&p2=2&p3=3

routing - Rails request parameters ignored when anchor present - Stack...

ruby-on-rails routing
Rectangle 27 31

jQuery BBQ is designed for parsing things from the url (query string or fragment), and goes a bit farther to simplify fragment-based history. This is the jQuery plugin Yarin was looking for before he put together a pure js solution. Specifically, the deparam.fragment() function does the job. Have a look!

(The support site I'm working on uses an asynchronous search, and because BBQ makes it trivial to tuck entire objects into the fragment I use it to 'persist' my search parameters. This gives my users history states for their searches, and also allows them to bookmark useful searches. Best of all, when QA finds a search defect they can link straight to the problematic results!)

@Hovis- this is indeed an awesome plugin, and in fact I've switched over to using it as well. Giving you the answer as it's a much better option than my scratch function.

BBQ doesn't work well with Jquery 1.9+ and throws exceptions on load. It hasn't been updated in over three years. I'm not sure BBQ is still a good recommendation. You may be able to hack it to get it to work, see this: github.com/cowboy/jquery-bbq/pull/41

jquery - Parsing URL hash/fragment identifier with JavaScript - Stack ...

javascript jquery url hash fragment-identifier
Rectangle 27 31

jQuery BBQ is designed for parsing things from the url (query string or fragment), and goes a bit farther to simplify fragment-based history. This is the jQuery plugin Yarin was looking for before he put together a pure js solution. Specifically, the deparam.fragment() function does the job. Have a look!

(The support site I'm working on uses an asynchronous search, and because BBQ makes it trivial to tuck entire objects into the fragment I use it to 'persist' my search parameters. This gives my users history states for their searches, and also allows them to bookmark useful searches. Best of all, when QA finds a search defect they can link straight to the problematic results!)

@Hovis- this is indeed an awesome plugin, and in fact I've switched over to using it as well. Giving you the answer as it's a much better option than my scratch function.

BBQ doesn't work well with Jquery 1.9+ and throws exceptions on load. It hasn't been updated in over three years. I'm not sure BBQ is still a good recommendation. You may be able to hack it to get it to work, see this: github.com/cowboy/jquery-bbq/pull/41

jquery - Parsing URL hash/fragment identifier with JavaScript - Stack ...

javascript jquery url hash fragment-identifier
Rectangle 27 4

Maybe with some modification you could use Fragment Identifier aka Hash (# sign in the Url) to change (part of) Url without page change.

Normally this is used to automatically navigate user to certain chapter in the page or initialize control to certain state. For example automatically select correct tab in the tab control. Ben Alman has an example about that (using jQuery BBQ).

ajax - Change browser address bar URL with jQuery - Stack Overflow

ajax jquery
Rectangle 27 4

Maybe with some modification you could use Fragment Identifier aka Hash (# sign in the Url) to change (part of) Url without page change.

Normally this is used to automatically navigate user to certain chapter in the page or initialize control to certain state. For example automatically select correct tab in the tab control. Ben Alman has an example about that (using jQuery BBQ).

ajax - Change browser address bar URL with jQuery - Stack Overflow

ajax jquery
Rectangle 27 4

Maybe with some modification you could use Fragment Identifier aka Hash (# sign in the Url) to change (part of) Url without page change.

Normally this is used to automatically navigate user to certain chapter in the page or initialize control to certain state. For example automatically select correct tab in the tab control. Ben Alman has an example about that (using jQuery BBQ).

ajax - Change browser address bar URL with jQuery - Stack Overflow

ajax jquery
Rectangle 27 15

You can't, the browser interprets the fragment (#folders=1) without sending it to the server. So if http://my.indiamart.com/cgi/my-enquiries.mp is your script, then it will never see the #folders=1 part of the URL as the browser won't send it. If you need the fragment on the server then you'll have to change it to a CGI parameter:

or embed it in the URL path, something like one of these:

http://my.indiamart.com/cgi/my-enquiries.mp/1
http://my.indiamart.com/cgi/my-enquiries.mp/folders=1

url - How to get parameter come after '#' in Perl CGI? - Stack Overflo...

perl url parameters cgi