I'm having some troubles while trying to open a local file in google-chrome as it gives me a weird URL in google chrome but prints just fine in the console.

Here is the output I get in the console:


Here is the address I get in chrome:


From what I've gathered so far it has to do with chrome escaping the "?" since they have to be interpreted server-side. Is there a way around it?

Thanks in advance

  • 1
    what are you trying to achieve? – Jakuje Sep 4 '15 at 18:35
  • Basically running an experiment. I need to open a local file in the browser with some parameters that are computed in a c++ program from which I'm calling the the system call to google chrome. – LBes Sep 4 '15 at 18:37
  • 1
    If you are calling local file, there is no "server-side" and everything is evaluated in browser. This is probably some chrome-feature showing potentially "dangerous" characters safely encoded, since I don't see this happening in Firefox. If the only problem is the way how it is visible in the url bar, I believe there is no problem ;) – Jakuje Sep 4 '15 at 18:41
  • There is actually a problem as I need to parse this URL in my local file which contains JavaScript and html. Unfortunately I have to use chrome because some of the JavaScript code that I use doesn't work on other browsers – LBes Sep 4 '15 at 18:44
  • If you get it "correctly" in (javascript) console there is nothing to do. Or it gets "translated" somewhere else on the way from C++ application? Can you be more specific about this? – Jakuje Sep 4 '15 at 18:55

In order to pass parameters to a client-side HTML page, when using local files, the hash # should be used instead of question marks ?.

So, basically: file:///home/user/Questionnaire/initialFr.html#id=902

| improve this answer | |
  • Interesting. Do you know how to link to a particular anchor in a page if the page is hosted locally, seeing as the # symbol is being used to replace the question mark? – ultrafez Sep 27 '15 at 12:16
  • @ultrafez I'm not quite sure (can't test it now), but I think using the # twice could work. I mean, for example, initialFr.html#id=902#anchor – nKn Sep 27 '15 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.