Welcome Guest, Not a member yet? Register   Sign In
# symbol in URL - what does this mean?
#1

[eluser]patsm[/eluser]
I'm editing someone elses application. There is a problem on one of the views and a javascript calendar is not functioning properly. What I noticed is in the URL that is generated, it shows a # symbol after the URL. Like this....

http://www.somedomain.com/C/index.php/cl...s/place_ad#

It is also displaying a # after the title name.

Can someone tell me what is causing the # to display? It may help in pinpointing my problem with the code.

Thanks.
#2

[eluser]Nick Husher[/eluser]
The # character is used to signal the browser to center the view on a particular named element.

So a link to www.example.com/#my-content will center on an element with an id of "my-content"

Many obtrusive javascript libraries will insert links like <a href="#"click="...">Javascript Link</a>, hence your mystery # at the end of the uri string. Note that anything that comes after the # will not be passed to the server through GET parameters.
#3

[eluser]Kinsbane[/eluser]
Helpful correction: a hash value in the URL signifies focusing on the element with the name="" attribute. Not the id. Smile
#4

[eluser]drewbee[/eluser]
exactly.

So

<a name="test-location"></a>My Test Location

If you visited /page.php#test-location it would drop the page down to where this is at. They are called anchors.
#5

[eluser]Nick Husher[/eluser]
Actually, either the name or ID work properly. Using the ID makes more sense, takes less code, and is arguably clearer.

Relevant W3C HTML 4.01 Spec, "Links in HTML documents":
Quote:Destination anchors in HTML documents may be specified either by the A element (naming it with the name attribute), or by any other element (naming with the id attribute).
(emphasis mine)
#6

[eluser]manilodisan[/eluser]
Lol...this thread is degrading CI...hahaha..Just a joke.
#7

[eluser]patsm[/eluser]
I do understand now what the # is for and in the javascript, the <a href="#"> tag is used.


However, this didn't help me find my problem. The old app's layout was done in css. So all I have done is create a table and dropped the <div> tags of the old app in the <td> of the new sitewide table. It all looks and works great except for this crazy javascript calendar. I get 2 errors: (1) 'document.getElementbyID (...)' is null or not an object (2) Object required.

I haven't changed any of the code; I just simply placed the <div> tags in a table so it would display a different look. So with these errors, does anyone have a clue of what I should be looking at to fix?

When I view the source code, it is displaying the javascript src correctly in the head so it must be importing it in.

I'm so frustrated!!!!
#8

[eluser]JoostV[/eluser]
Search for the the id that is mentioned in javascript error 'document.getElementbyID (...)'. The error tells you that it cannot be found in the page.

Did you take content out of a div with an id tag, such as <div id="very_important_div">? This would explain why javascript cannot find the ID anymore.
#9

[eluser]Colin Williams[/eluser]
Quote:Helpful correction: a hash value in the URL signifies focusing on the element with the name=”“ attribute. Not the id.

Ha! You mean Misleading correction? The "#foo" in a URI is known as a "Fragment Identifier" and it works just like others in this thread have correctly.

Here's a rough anatomy of a URI

scheme://host.name.com/directory/file.php/path/info?query=string#fragment




Theme © iAndrew 2016 - Forum software by © MyBB