<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>https://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>https://jackxiang.com/post//</link>
<title><![CDATA[PHP Header用于页面跳转要注意的几个问题总结，php的js页面跳转方法]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Fri, 15 Jan 2010 06:57:53 +0000</pubDate> 
<guid>https://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	1、location和“:”号间不能有空格，否则会出错。<br/>2、在用header前不能有任何的输出。<br/>3、header后的PHP代码还会被执行。<br/>下面是和asp中重定向response.redirect的比较：<br/>例1:<br/><textarea name="code" class="html" rows="15" cols="100">
response.redirect &quot;../test.asp&quot;
header(&quot;location:../test.php&quot;);
</textarea><br/>两者区别:<br/>asp的redirect函数可以在向客户发送头文件后起作用.<br/>如<br/><textarea name="code" class="html" rows="15" cols="100">
&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;
&lt;%response.redirect &quot;../test.asp&quot;%&gt;
&lt;/body&gt;&lt;/html&gt;
</textarea>查是php中下例代码会报错:<br/><textarea name="code" class="html" rows="15" cols="100">
&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;
&lt;?
header(&quot;location:../test.php&quot;);
?&gt;
&lt;/body&gt;&lt;/html&gt;
</textarea><br/>只能这样:<br/><br/><textarea name="code" class="html" rows="15" cols="100">&lt;?
header(&quot;location:../test.php&quot;);
?&gt;
&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;...&lt;/body&gt;&lt;/html&gt;</textarea>即header函数之前不能向客户发送任何数据.<br/>例2:<br/>asp中<br/><br/><textarea name="code" class="html" rows="15" cols="100">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;
&lt;%
response.redirect &quot;../a.asp&quot;
response.redirect &quot;../b.asp&quot;
%&gt;
&lt;/body&gt;&lt;/html&gt;</textarea>结果是重定向a.asp文件.<br/>php呢?<br/><br/><textarea name="code" class="html" rows="15" cols="100">&lt;?
header(&quot;location:../a.php&quot;);
header(&quot;location:../b.php&quot;);
?&gt;
&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;</textarea>我们发现它重定向b.php.<br/>原来在asp中执行redirect后不会再执行后面的代码.<br/>而php在执行header后,继续执行下面的代码.<br/>在这方面上php中的header重定向不如asp中的重定向.有时我们要重定向后,不能执行后面的代码:<br/>一般地我们用<br/><br/><textarea name="code" class="html" rows="15" cols="100">if(...)
header(&quot;...&quot;);
else
&#123;
...
&#125;</textarea>但是我们可以简单的用下面的方法:<br/><br/><textarea name="code" class="html" rows="15" cols="100">if(...)
&#123; header(&quot;...&quot;);exit();&#125;</textarea><br/>还要注意的是，如果是用Unicode(UTF-8)编码时也会出现问题，需要调整缓存设置.<br/><br/><textarea name="code" class="html" rows="15" cols="100">&lt;[email=%@]%@LANGUAGE=&quot;VBSCRIPT[/email]&quot; CODEPAGE=&quot;936&quot;%&gt;
&lt;%if Request.ServerVariables(&quot;SERVER_NAME&quot;)=&quot;s.jb51.net&quot; then
response.redirect &quot;news/index.htm&quot;
else%&gt;
&lt;%end if%&gt;
&lt;script&gt;
var url = location.href;
if(url.indexOf(&#039;http://www.jb51.net/&#039;)!=-1)location.href=&#039;/index/index.htm&#039;;
if(url.indexOf(&#039;http://www.kanshule.com/&#039;)!=-1)location.href=&#039;/index1/index.htm&#039;;
if(url.indexOf(&#039;http://www.shouji17.com/&#039;)!=-1)location.href=&#039;/cn/index.asp&#039;;
if(url.indexOf(&#039;http://www.baidu.com/&#039;)!=-1)location.href=&#039;/cn/index.asp&#039;;
&lt;/script&gt;</textarea><br/>php的js页面跳转方法：<br/>第一种:<br/><br/><textarea name="code" class="html" rows="15" cols="100">echo &quot;&lt; meta http-equiv=&#92;&#92;&quot;Refresh&#92;&#92;&quot; content=&#92;&#92;&quot;秒数; url=跳转的文件或地址&#92;&#92;&quot; &gt; &quot;;</textarea>其中:XX是秒数,0为立即跳转.refresh 是刷新的意思.Url 是要跳转到的页面.<br/><br/>第二种:利用script实现<br/><br/><textarea name="code" class="html" rows="15" cols="100">&lt;script&gt;url=&quot;submit.php&quot;;window.location.href=url;&lt;/script&gt;</textarea><br/>第三种:利用script实现,所不同的是使用 open 语句.且可以限制原窗口还是父窗口,子窗口或者新窗口.<br/><br/><textarea name="code" class="html" rows="15" cols="100">&lt;script&gt;url=&quot;submit.php&quot;;window.open(&#92;&#039;url,&#92;&#039;&#92;&#039;,&#92;&#039;_self&#92;&#039;);&lt;/script&gt;</textarea>其中 更改&#92;&#039;_self&#92;&#039; 就可以实现跳转限制原窗口还是父窗口,子窗口或者新窗口.第四种:利用php自带函数发送头部信息<br/><br/><textarea name="code" class="html" rows="15" cols="100">header(&quot;Location: Url&quot;);</textarea><br/><br/>速度最快,功能强大...但是有个问题必须指出:如果在使用这个函数前已经有html输出,哪怕是一个空格.那么在页顶会显示错误信息.. 
]]>
</description>
</item><item>
<link>https://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] PHP Header用于页面跳转要注意的几个问题总结，php的js页面跳转方法]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>