# Weird error with document.location.hash

**URL:** <https://forum.kirupa.com/t/weird-error-with-document-location-hash/319130>\
**Category:** web dev\
**Created:** [February 9, 2011, 8:07pm UTC](https://forum.kirupa.com/t/weird-error-with-document-location-hash/319130 "2011-02-09T20:07:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashgroove](https://avatars.discourse-cdn.com/v4/letter/f/b5e925/32.png) [@flashgroove](https://forum.kirupa.com/u/flashgroove)\
**Post date:** [February 9, 2011, 8:07pm UTC](https://forum.kirupa.com/t/weird-error-with-document-location-hash/319130/1 "2011-02-09T20:07:44Z")

</div>

I am having a weird error with the document.location.hash property.

I have a function that receives a parameter which is then applied to this property.

If the parameter has the “#” sign applied when the function receives it then it works, but if the “#” sign is concatenated inside the function then it does not work.

This works:

```auto

function update(address)
{
	window.location.hash = address;
}
(When address = "#test")

```

This does not work:

```auto

function update(address)
{
	window.location.hash = "#" + address;
}
(When address = "test")

```

Is there a reason why this is happening ?
