Search code examples
coldfusioncoldfusion-9cflocation

Redirect to a new tab using CFLocation - CF9


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>

Solution

  • 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>