Window.location.href + hash error in Safari?

I have a script in my JavaScript file where I need to open a new file with a hash already installed, something like:

function search(queryString){
    window.location.href = "dosome.php#" + queryString
}

because dosome.php is the page where I have all the scripts to search for ...

I know this sounds like a hack, but I can't rebuild anymore. I'm just trying to fix it temporarily.

It works in Firefox and Chrome, but for some reason it does not work in Safari - it does not send a hash url. Safari sends:

domain.com/dosome.php

instead

domain.com/dosome.php#queryvalues

What could be the problem?

+3
source share
3 answers

If your server dosome.phpdoesn’t do some redirects, the hash is NOT saved, at least on Safari 4 and IE8. Chrome and Firefox work well.

, URL- http://yourdomain.com/...dosome.php#... Safari , Safari #. ( w/o www, www #.)

, , #... ; , .

+5

? , dosome.php?

location.hash,

location.hash = "#somestring";
+1

.

iPhone 5 Safari:

window.location.href = 'http://example.com/result#somehash'

Safari http://example.com/result/

Chrome , .

, , .

!

I changed my code to this and it worked:

window.location.href = 'http://example.com/result/#somehash'

Pay attention to / before the hash.

+1
source

All Articles