Getting the Named Anchor using ColdFusion

怎甘沉沦 提交于 2020-01-04 04:10:07

问题


How can I get the URL using ColdFusion?

I tried the following but it did not return the Named Anchor.

For example http://www.makeup.edu/test/#abc

<cfdump var=#cgi#>

回答1:


You can't, 'cause although it is in the URL, it is only meant for the client. It will not be sent to the server, therefore you can never find that in the CGI scope.




回答2:


As Henry says, you can't get them with ColdFusion because they are never sent with the request. What you need to do is to pull them out with Javascript (which can access them), and then send them back to the server via some other mechanism, like putting them in a cookie or something. It depends on the situation as to how you tackle that part, but it's probably a different question anyhow.

Bottom line: the info is never transmitted with the request, so the web server doesn't get it, so the web server cannot pass it to ColdFusion, so ColdFusion does not receive it.




回答3:


Add an additional url parameter to identify the anchor. So you could create the link http://www.makeup.edu/test/?anchor=1#abc

The user clicks on the link and the anchor goes to the right place and then you could use:

<cfif ISDEFINED("url.anchor")>
  <cfif url.anchor EQ 1>
     ... do stuff here...
  </cfif>
</cfif>


来源:https://stackoverflow.com/questions/17734612/getting-the-named-anchor-using-coldfusion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!