{"id":46,"date":"2011-12-26T06:52:03","date_gmt":"2011-12-26T06:52:03","guid":{"rendered":"http:\/\/www.shuran.cn\/?p=46"},"modified":"2012-02-08T04:07:06","modified_gmt":"2012-02-08T04:07:06","slug":"ie8%e4%b8%8a%e4%bc%a0%e6%96%87%e4%bb%b6%e6%97%b6fakepath-%e7%9a%84%e8%a7%a3%e5%86%b3%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.shuran.cn\/?p=46","title":{"rendered":"IE8\u4e0a\u4f20\u6587\u4ef6\u65f6fakepath \u7684\u89e3\u51b3\u65b9\u6cd5"},"content":{"rendered":"<p>IE8\uff0c\u6ca1\u60f3\u5230\u4e00\u4e2a\u7f51\u7ad9\u91cc\u9762\u7684\u4e0a\u4f20\u56fe\u7247\u65f6\u7528JavaScript\u9884\u89c8\u672c\u5730\u56fe\u7247\u7684\u529f\u80fd\u5931\u6548\u4e86\uff0c\u56fe\u7247\u603b\u662f\u663e\u793a\u9519\u8bef\uff0c\u7528alert()\u770b\u4e86\u4e0b\u56fe\u7247\u7684\u8def\u5f84\u5c45\u7136\u53d8\u6210\u4e86C:\\fakepath\\*.jpg\uff0c\u771f\u5b9e\u7684\u8def\u5f84\u88abC:\\fakepath\\\u53d6\u4ee3\u4e86\uff0c\u4e8e\u662f\u5728\u7f51\u4e0a\u5f00\u59cb\u627e\u89e3\u51b3\u65b9\u6848\u3002\u539f\u6765\u662f\u56e0\u4e3aIE8\u589e\u52a0\u4e86\u5b89\u5168\u9009\u9879\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u4e0d\u663e\u793a\u4e0a\u4f20\u6587\u4ef6\u7684\u771f\u5b9e\u8def\u5f84\uff0c\u8fdb\u5165internet\u9009\u9879\uff0c\u4fee\u6539\u4e0b\u8bbe\u7f6e\u5373\u53ef\u663e\u793a\u771f\u5b9e\u7684\u6587\u4ef6\u8def\u5f84\u3002<\/p>\n<p>\u5de5\u5177 -&gt; Internet\u9009\u9879 -&gt; \u5b89\u5168 -&gt; \u81ea\u5b9a\u4e49\u7ea7\u522b -&gt; \u627e\u5230\u201c\u5176\u4ed6\u201d\u4e2d\u7684\u201c\u5c06\u672c\u5730\u6587\u4ef6\u4e0a\u8f7d\u81f3\u670d\u52a1\u5668\u65f6\u5305\u542b\u672c\u5730\u76ee\u5f55\u8def\u5f84\u201d\uff0c\u9009\u4e2d\u201c\u542f\u7528\u201d\u5373\u53ef\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>\u9644\u5e26\u4e0d\u7528\u4fee\u6539\u6d4f\u89c8\u5668\u5b89\u5168\u914d\u7f6e\u7684javascript\u4ee3\u7801\uff0c\u517c\u5bb9ie\uff0c firefox\u5168\u7cfb\u5217<\/p>\n<ol>\n<li>function getPath(obj)<\/li>\n<li>{<\/li>\n<li>\u00a0\u00a0if(obj)<\/li>\n<li>\u00a0\u00a0 {<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0if (window.navigator.userAgent.indexOf(\"MSIE\")&gt;=1)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0 {<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 obj.select();<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return document.selection.createRange().text;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0 }<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0else if(window.navigator.userAgent.indexOf(\"Firefox\")&gt;=1)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0 {<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if(obj.files)<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return obj.files.item(0).getAsDataURL();<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0return obj.value;<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0 }<\/li>\n<li>\u00a0\u00a0\u00a0\u00a0return obj.value;<\/li>\n<li>\u00a0\u00a0 }<\/li>\n<li>}<\/li>\n<\/ol>\n<p>\u53c2\u6570obj\u4e3ainput file\u5bf9\u8c61<\/p>\n<p>&nbsp;<\/p>\n<p>\u5b9e\u4f8b\uff1ajs\u90e8\u5206<\/p>\n<p>function SeePic(img,f){<br \/>\n\u00a0\u00a0 if ( f.value != \"\" ) { img.src = f.value; }<br \/>\n}<br \/>\nvar onecount;<br \/>\nonecount=0;<br \/>\n&lt;{counter start=-1 skip=1 print=false}&gt;<br \/>\nsubcat = new Array();<br \/>\n&lt;{section name=list loop=$categorys}&gt;<br \/>\n&lt;{section name=list2 loop=$categorys[list].list}&gt;<br \/>\nsubcat[&lt;{counter}&gt;] = new Array(\"&lt;{$categorys[list].list[list2].name}&gt;\",\"&lt;{$categorys[list].id}&gt;\",\"&lt;{$categorys[list].list[list2].id}&gt;\");<br \/>\n&lt;{\/section}&gt;<br \/>\n&lt;{\/section}&gt;<br \/>\nonecount=&lt;{counter}&gt;;<br \/>\n&lt;{literal}&gt;<br \/>\nfunction changelocation(locationid)<br \/>\n\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0 document.form1.category_id2.length = 0;<br \/>\n\u00a0\u00a0\u00a0 var locationid=locationid;<br \/>\n\u00a0\u00a0\u00a0 var i;<br \/>\n\u00a0\u00a0\u00a0 for (i=0;i &lt; onecount; i++)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (subcat[i][1] == locationid)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 document.form1.category_id2.options[document.form1.category_id2.length] = new Option(subcat[i][0], subcat[i][2]);<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/>\n\u00a0\u00a0\u00a0 }\u00a0\u00a0<br \/>\n&lt;{\/literal}&gt;<\/p>\n<p>&nbsp;<\/p>\n<p>Html\u90e8\u5206\uff1a<\/p>\n<p>&lt;div&gt;&lt;input name=\"litimg\" type=\"file\" onChange=\"SeePic(document.picview,document.form1.litimg);\" \/&gt;&lt;br&gt;\u9996\u9875615*321&lt;br&gt;&lt;img src=\"style\/img\/pview.gif\" id=\"picview\" name=\"picview\"&gt;&lt;\/div&gt;<\/p>\n<p>\u4fee\u6539\u540eJS\u90e8\u5206\uff1a<\/p>\n<p>function getPath(obj)\u00a0 {\u00a0\u00a0\u00a0 if(obj)\u00a0\u00a0\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (window.navigator.userAgent.indexOf(\"MSIE\")&gt;=1)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 obj.select();\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return document.selection.createRange().text;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 else if(window.navigator.userAgent.indexOf(\"Firefox\")&gt;=1)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if(obj.files)\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return obj.files.item(0).getAsDataURL();\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return obj.value;\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0\u00a0\u00a0 return obj.value;\u00a0\u00a0\u00a0\u00a0\u00a0 }\u00a0 }\u00a0<\/p>\n<p>function SeePic(img,f){<br \/>\n\u00a0\u00a0 if ( f.value != \"\" ) { img.src = getPath(f); }<br \/>\n}<br \/>\nvar onecount;<br \/>\nonecount=0;<br \/>\n&lt;{counter start=-1 skip=1 print=false}&gt;<br \/>\nsubcat = new Array();<br \/>\n&lt;{section name=list loop=$categorys}&gt;<br \/>\n&lt;{section name=list2 loop=$categorys[list].list}&gt;<br \/>\nsubcat[&lt;{counter}&gt;] = new Array(\"&lt;{$categorys[list].list[list2].name}&gt;\",\"&lt;{$categorys[list].id}&gt;\",\"&lt;{$categorys[list].list[list2].id}&gt;\");<br \/>\n&lt;{\/section}&gt;<br \/>\n&lt;{\/section}&gt;<br \/>\nonecount=&lt;{counter}&gt;;<br \/>\n&lt;{literal}&gt;<br \/>\nfunction changelocation(locationid)<br \/>\n\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0 document.form1.category_id2.length = 0;<br \/>\n\u00a0\u00a0\u00a0 var locationid=locationid;<br \/>\n\u00a0\u00a0\u00a0 var i;<br \/>\n\u00a0\u00a0\u00a0 for (i=0;i &lt; onecount; i++)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (subcat[i][1] == locationid)<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 document.form1.category_id2.options[document.form1.category_id2.length] = new Option(subcat[i][0], subcat[i][2]);<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 }<br \/>\n\u00a0\u00a0\u00a0 }\u00a0\u00a0<br \/>\n&lt;{\/literal}&gt;<\/p>\n<p>&lt;\/script&gt;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>IE8\uff0c\u6ca1\u60f3\u5230\u4e00\u4e2a\u7f51\u7ad9\u91cc\u9762\u7684\u4e0a\u4f20\u56fe\u7247\u65f6\u7528JavaScript\u9884\u89c8\u672c\u5730\u56fe\u7247\u7684\u529f\u80fd\u5931\u6548\u4e86\uff0c\u56fe\u7247\u603b\u662f\u663e\u793a\u9519\u8bef\uff0c\u7528al\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.shuran.cn\/?p=46\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-46","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=46"}],"version-history":[{"count":3,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":48,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=\/wp\/v2\/posts\/46\/revisions\/48"}],"wp:attachment":[{"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shuran.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}