I'm working on a project that uses a <? header('Location: http://url.com'); ?>
for redirects, and I'm very pleased with it because of the speed and the fact that it doesn't flash some intermediary URL in the address bar before redirecting. However, I now need to call my tracking software via a piece of Javascript li开发者_开发百科ke so:
<script type="text/javascript" src="MYSCRIPT"></script>
Is there any way to get the best of both words? I.e. call my tracking software via the javascript and still use the php redirect? Or will I have to switch to a JS window.location
redirect if I want to call this script?
Thanks!
You will either have to write the JavaScript code for your tracking in PHP and execute it before the redirect, or have a page with one of those 'you are being redirected' if you want to use Javascript.
The problem is that you cannot modify the header information after it has been sent. i.e. you can't have anything after header('Location:'); redirect.
精彩评论