Pergunta

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>
Foi útil?

Solução 2

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>

Outras dicas

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

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top