Question

Whenever I submit a form rails append a unknown fragment in params in the url. But what is the purpose of that fragment ? and how I can get rid of it? Please refer to following sample URL.

By token I am referring to "#.U3Mw4XKHbFY" in the following URL

Here is URL sample

www.domain.com/posts?utf8=%E2%9C%93&query=surf&area=All+Area#.U3Mw4XKHbFY

<%= form_tag posts_path, method: 'get', class: "search_keywords_form" do %>
  <%= text_field_tag :query, nil, class: "search-field", placeholder: "Search Item for swap" %>
  <%= hidden_field_tag 'area', "All Area" %>  
  <input type="submit" class="search-btn" value="" />

  <div class="clearfix"></div>
  <div class="push"></div>
<% end %>

Another strange thing is when I review the params, I don't get it there. But when page get reloaded That unknown attribute get appended.

params = { "utf8"=>"✓",
           "query"=>"surf",
           "area"=>"All Area",
           "action"=>"index",
           "controller"=>"posts"
         }
Was it helpful?

Solution

I also had to face this problem, this is definitely JS problem might be some plugin would be appending this.

Simple solution for this is just put location.hash = "" in your js file on document ready. And yes i remembered, this fragment is appended when you use some tracking system. Like google analytics or Addthis

OTHER TIPS

What are you talking about is the fragment part of an URI. The fragment part of the URI refers to some part of the HTML content response, and it is processed only client side: that's why you don't - and you can't - see or process it server side.

The fragment appears because it is present somewhere in the HTML form, or because some client side code (aka JavaScript) sets it to the form URL.

I have the feeling I have already seen that fragment pattern somewhere, but I don't remember where...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top