Redirect to a new tab using CFLocation - CF9

こ雲淡風輕ζ 提交于 2019-12-02 00:03:54

问题


Is there a way to redirect a user to a new window by using CFLocation? As far as I know you cannot use target=_blank in CFLocation. Is there another way to do it?

This is my code:

    <cfif cgi.PATH_INFO eq "/procedure-page.cfm">
       <cflocation url="http://www.example.com/example/example.cfm?id=XXXXXX&contactid=#returnStruct.contactID#&doctorid=#officeLocation#" addtoken="no" >
    <cfelse>
       <cflocation url="http://www.example.com/example/example.cfm?id=#example#&contactid=#returnStruct.contactID#&doctorid=#officeLocation#" addtoken="no" >
    </cfif>

回答1:


This is probably not the cleanest way, but it should work.

<cfoutput>
<cfif cgi.PATH_INFO eq "/procedure-page.cfm">
    <script type="text/javascript">
        window.open("http://www.example.com/example/example.cfm?id=XXXXXX&contactid=#returnStruct.contactID#&doctorid=#officeLocation#", '_blank');
    </script>
<cfelse>
    <script type="text/javascript">
        window.open("http://www.example.com/example/example.cfm?id=#example#&contactid=#returnStruct.contactID#&doctorid=#officeLocation#", '_blank');
    </script>
</cfif>
</cfoutput>



回答2:


<cflocation> performs a client-side redirect, but it's initiated on the server side (it sends a request with a redirect in the header), so it can't know anything about "tabs" which are a browser thing. CF doesn't know anything about what's going on in the browser.

To do the sort of thing you want to do on the client site, you need to do the browser stuff with Javascript.




回答3:


I believe Adam is correct in that CFLocation cannot ask the browser to open in a new window (or tab). Something that might interest you however is the CFWindow tag. See the documentation here. Note that CFWindow does not open a new browser window either, but creates a <div> to simulate a popup window. Anyway, it has several options and I thought it might be worth you taking a look at. Maybe it can handle what you need.



来源:https://stackoverflow.com/questions/14347092/redirect-to-a-new-tab-using-cflocation-cf9

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