C# Menu 导航菜单控件Apple Safari & Google Chrome浏览器上显示无效问题
from: http://social.msdn.microsoft.com/Forums/zh-TW/236/thread/78f5f655-f378-4662-b73d-b6371d03f20c
1.在网站內新增一个项目叫做 浏览器文件", 它自动会产生一个App_Browsers的目录, 包含一个叫BrowserFile.browser的文件.
2.在App_Browsers的目录下再新增一个 "浏览器文件"项目,取名为Others.browser.
文件代码为:
代码
1 <!--
2 You can find existing browser definitions at
3 <windir>\Microsoft.NET\Framework\<ver>\CONFIG\Browsers
4 -->
5 <browsers>
6 <browser id="NewBrowser" parentID="Mozilla">
7 <identification>
8 <userAgent match="Unique User Agent Regular Expression" />
9 </identification>
10
11 <capture>
12 <userAgent match="NewBrowser (?'version'\d+\.\d+)" />
13 </capture>
14
15 <capabilities>
16 <capability name="browser" value="My New Browser" />
17 <capability name="version" value="${version}" />
18 </capabilities>
19 </browser>
20
21 <browser refID="Mozilla">
22 <capabilities>
23 <capability name="xml" value="true" />
24 </capabilities>
25 </browser>
26
27 <browser id ="Safari3" parentID ="Safari1Plus">
28 <identification >
29 <userAgent match ="Safari/\d+\.\d+"/>
30 </identification>
31 <capture>
32 <userAgent match ="Version/(?'version'\d+\.\d+)"/>
33 </capture>
34 <capabilities>
35 <capability name ="browser" value ="Safari3"/>
36 <capability name ="version" value ="${version}"/>
37 </capabilities>
38 <controlAdapters>
39 <adapter controlType ="System.Web.UI.WebControls.Menu"
40 adapterType =""/>
41 </controlAdapters>
42 </browser>
43 <browser id ="GoogleChrome" parentID ="Safari3">
44 <identification>
45 <userAgent match ="Chrome/(?'version'\d+\.\d+)"/>
46 </identification >
47 <capabilities >
48 <capability name ="browser" value ="Googlebot"/>
49 </capabilities>
50 </browser>
51 </browsers>
2 You can find existing browser definitions at
3 <windir>\Microsoft.NET\Framework\<ver>\CONFIG\Browsers
4 -->
5 <browsers>
6 <browser id="NewBrowser" parentID="Mozilla">
7 <identification>
8 <userAgent match="Unique User Agent Regular Expression" />
9 </identification>
10
11 <capture>
12 <userAgent match="NewBrowser (?'version'\d+\.\d+)" />
13 </capture>
14
15 <capabilities>
16 <capability name="browser" value="My New Browser" />
17 <capability name="version" value="${version}" />
18 </capabilities>
19 </browser>
20
21 <browser refID="Mozilla">
22 <capabilities>
23 <capability name="xml" value="true" />
24 </capabilities>
25 </browser>
26
27 <browser id ="Safari3" parentID ="Safari1Plus">
28 <identification >
29 <userAgent match ="Safari/\d+\.\d+"/>
30 </identification>
31 <capture>
32 <userAgent match ="Version/(?'version'\d+\.\d+)"/>
33 </capture>
34 <capabilities>
35 <capability name ="browser" value ="Safari3"/>
36 <capability name ="version" value ="${version}"/>
37 </capabilities>
38 <controlAdapters>
39 <adapter controlType ="System.Web.UI.WebControls.Menu"
40 adapterType =""/>
41 </controlAdapters>
42 </browser>
43 <browser id ="GoogleChrome" parentID ="Safari3">
44 <identification>
45 <userAgent match ="Chrome/(?'version'\d+\.\d+)"/>
46 </identification >
47 <capabilities >
48 <capability name ="browser" value ="Googlebot"/>
49 </capabilities>
50 </browser>
51 </browsers>
p.s. 如果上述方法搞不定的話, 可以在Page_Load的地方加一代码:
c#:
1 if(Request.UserAgent.IndexOf("AppleWebKit") > 0)
2 {
3 Request.Browser.Adapters.Clear();
4 }
2 {
3 Request.Browser.Adapters.Clear();
4 }
在 Page_PreInit加上代码
1 if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
2 {
3 this.ClientTarget = "uplevel";
4 }
2 {
3 this.ClientTarget = "uplevel";
4 }
VB:
1 If Request.UserAgent.IndexOf("AppleWebKit") > 0 Then Request.Browser.Adapters.Clear()
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)