本文介绍了jQuery:跨浏览器问题 - 调试Internet Explorer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 更新:问题似乎是由于编写了JavaScript以解决Firefox / flash的问题,该程序现在正试图在IE中播放html5,这对IE 8及更早版本无效。但是,如果我在标题 http://html5media.info/ 中放置基于javascript的html5链接,则html5播放器可以正常工作在IE 8中,但没有任何可行的方式。所有玩家立即显示并开始自动播放。请注意,我的所有学生都在亚洲,所以游戏必须在IE 8中运行... 我使用jQuery / JavaScript为英语学习者制作了一个游戏游戏在这里的第二语言。它适用于Chrome,Firefox和Safari,但不适用于Internet Explorer。我不知道如何弄清IE中的问题,但似乎是一个非常简单的javascript问题,jQuery的跨浏览器兼容性不应该有问题,除非我的代码太糟糕我搞砸了它以某种方式(注意我是一个相对的新手) 该游戏使用16种不同的录音,因此有16种不同的音频播放器。但是,每个音频播放器都是隐藏的使用css display:none 然后再次出现 .css('display','block'); 但在IE浏览器中它无法正常工作 使用JavaScript,我随机选择1到16之间的数字,然后根据它选择一个音频播放器。这一切都发生在你点击游戏主页上的开始时。然而,在IE中,当我点击开始时音频播放器没有显示。这看起来像一个相当基本的JavaScript问题,我认为jQuery不会有跨浏览器问题,注意,JavaScript的其他部分似乎在IE工作。例如,如果您单击游戏底部的一个字母,它会告诉您猜测是对还是错(基于您应该听到的音频)。 我还注意到在IE浏览器页面需要很长时间才能加载(5分钟后,它仍然会在底部显示16个项目。)我认为这些可能是音频播放器。在其他浏览器中,这不会发生。 对我来说,游戏在IE中工作是非常重要的,因为我为它制作的学生都在日本,而且大多数都使用IE浏览器 任何人都可以帮我在IE中调试这个或者让我知道如何在IE中调试它吗? 这是应该使音频播放器出现的代码。取决于浏览器是使用Flash还是HTML5(使用行检测到if($('#ONE')。长度)),然后jQuery使用show或.css('display','block')来显示音频播放器。假设IE正在选择flash,那么它正在使用 .css('display','block') 使音频播放器出现(不成功) jQuery使音频播放器出现 function test(){ $(。start)。click(function(){ ran = getRandom(myArray,true); if($('#ONE')。length){ $('#'+ ran).show(); } else { $('#f-'+ ran).css('display','block'); } }); 更新,这是来自音频插件的PHP文件 ## WPaudio版本 $ wpa_version ='3.1'; ## Pre-2.6兼容性(来自WP codex) if(!defined('WP_CONTENT_URL')) define('WP_CONTENT_URL',get_option('siteurl')。 '/ wp-content'); if(!defined('WP_CONTENT_DIR')) define('WP_CONTENT_DIR',ABSPATH。'wp-content'); if(!defined('WP_PLUGIN_URL')) define('WP_PLUGIN_URL',WP_CONTENT_URL。'/ plugins'); if(!defined('WP_PLUGIN_DIR')) define('WP_PLUGIN_DIR',WP_CONTENT_DIR。'/ plugins'); if(!defined('WPAUDIO_URL')) define('WPAUDIO_URL',WP_PLUGIN_URL。'/ wpaudio-mp3-player'); ##从DB获取WPaudio的选项(如果没有找到则创建它们) $ wpa_options = wpaOptions(); ## WP处理程序 - 在必要的事件中添加WPaudio处理#如果它不是管理页面,请获取播放器的所有内容 if(!is_admin()){#调用脚本 add_action('init','wpaLibraries'); #添加标题操作以包含CSS和JS变量 add_action('wp_head','wpaHead'); #为WPaudio播放器添加短代码 add_shortcode('wpaudio','wpaShortcode'); #在摘录和小部件中添加短代码过滤器 add_filter('the_excerpt','do_shortcode'); add_filter('widget_text','do_shortcode'); #为非短代码替换添加过滤器(包括摘录和小部件) if($ wpa_options ['wpa_tag_audio']){ add_filter('the_content','wpaFilter'); add_filter('the_excerpt','wpaFilter'); add_filter('widget_text','wpaFilter'); } } #添加admin add_action('admin_menu','wpa_menu'); #添加曲目 if($ wpa_options ['wpa_track_permalink'])add_action('publish_post','wpaPostNew'); 函数wpaOptions(){ ## WPA选项和默认值 global $ wpa_version; $ wpa_options =数组('wpa_version'=> $ wpa_version,'wpa_pref_link_mp3'=> 0,'wpa_tag_audio'=> 0, 'wpa_track_permalink'=> 1,'wpa_style_text_font'=>'Sans-serif','wpa_style_text_size'=>'18px','wpa_style_text_weight'=>'正常','wpa_style_text_letter_spacing'=>'普通','wpa_style_text_color'=>'继承','wpa_style_link_color'=>'#24f',' wpa_style_link_hover_color'=>'#02f','wpa_style_bar_base_bg'=>'#eee','wpa_style_bar_load_bg'=>'#ccc','wpa_style_bar_position_bg'=> '#46f','wpa_style_sub_color'=>'#aaa'); if($ wpa_options_db = get_option('wpaudio_options')){ foreach($ wpa_options as $ key => $ value){ if(isset($ wpa_options_db [$ key]) ){ $ wpa_options [$ key] = $ wpa_options_db [$ key]; } } } else {#获取遗留选项,如果存在则删除 if(get_option('wpa_tag_audio')){ foreach($ wpa_options as $ key => $ value){ $ wpa_option_old_db = get_option($ key); if($ wpa_option_old_db!== false&& $ wpa_option_old_db!==''){ $ wpa_options [$ key] = $ wpa_option_old_db; } delete_option($ key); } } #创建wpaudio_options add_option('wpaudio_options',$ wpa_options,'','no'); // update_option('wpaudio_options',$ wpa_options); } 返回$ wpa_options; } ##内置库函数wpaLibraries(){ global $ wpa_version; // wp_deregister_script('jquery'); // wp_register_script('jquery','http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js','1.4.3'); if(version_compare(get_bloginfo('version'),'2.8','> =')){ if(WP_DEBUG === false){ wp_register_script('wpaudio', WPAUDIO_URL。'/ wpaudio.min.js',Array('jquery'),$ wpa_version,true); } else { wp_register_script('wpaudio',WPAUDIO_URL。'/ wpaudio.js',Array('jquery'),$ wpa_version,true); } wp_enqueue_script('wpaudio'); } else { wp_enqueue_script('jquery'); add_action('wp_footer','wpaFooterForOldVersions'); } } ## WPaudio样式,jQuery,SWFObject 函数wpaHead(){ global $ wpa_options; #将所有样式放入_wpaudio设置对象 $ style =''; foreach($ wpa_options as $ key => $ value){ $ explosion = explode('_',$ key,3); if($ explosion [1] =='style'){ $ style。= $ explosion [2]。 : $值,; } } $ style = trim($ style,','); $ style ='{'。 $ style。 }; #Common JS $ wpa_pref_link_mp3 =($ wpa_options ['wpa_pref_link_mp3'])? '真假'; $ head =< script type ='text / javascript'> / *<![CDATA [* / var _wpaudio = {url:'。 WPAUDIO_URL。 ',enc:{},convert_mp3_links:$ wpa_pref_link_mp3,style:$ style}; / *]]> * /< / script>; echo $ head; } 函数wpaFooterForOldVersions(){ echo'< script type =text / javascriptsrc ='。WPAUDIO_URL。'/ wpaudio.min.js> ;< /脚本>'; } #仅用于wpaudio短代码标签函数wpaShortcode($ atts){#根据设置将短信码转换为WPaudio播放器 extract( shortcode_atts(数组('url'=> false,'text'=> false,'dl'=> true,'autoplay'=> false ),$ atts)); #如果没有网址,如果(!$ url)返回则不返回; #获取播放器HTML和JS 返回wpaLink($ url,$ text,$ dl,$ autoplay); } #使WPA链接函数wpaLink($ url,$ text = false,$ dl = true,$ autoplay = false){ $ id = uniqid( 'wpaudio-'); $ class ='wpaudio'; $ html =''; #处理dl网址,没有dl玩家 if($ dl =='0'){ $ js_url = wpaUnicode($ url); $ href ='#'; $ class。='wpaudio-nodl'; } elseif(is_string($ dl)){ $ js_url = wpaUnicode($ url); $ href = $ dl; } else { $ href = $ url; } if(isset($ js_url)){ $ class。='wpaudio-enc'; $ html。=< script type ='text / javascript'> _wpaudio.enc ['$ id'] ='$ js_url';< / script>; } #处理空白文本 if(!$ text){ $ text = basename($ url); $ class。='wpaudio-readid3'; } #Autoplay if($ autoplay =='1'){ $ class。='wpaudio-autoplay'; } $ html。=< a id ='$ id'class ='$ class'href ='$ href'> $ text< / a>; 返回$ html; } #用于音频标签功能wpaFilter($ content){ ##根据设置转换音频标签和指向WPaudio播放器的链接 $ tag_regex ='/\ _audio :(.*?)\} /'; $ tag_match = preg_match_all($ tag_regex,$ content,$ tag_matches); #用播放器链接替换音频标签 if($ tag_match){ foreach($ tag_matches [1] as $ key => $ value){#这是一个标签,首先获取参数和URL $ params = explode('|',$ value); $ clips = Array('urls'=> Array(),'titles'=> Array(),'artists'=> Array()); $ clips ['urls'] = explode(',',$ params [0]); #处理额外参数(如果它们存在) for($ i = 1; $ i< count($ params); $ i ++){#获取参数名称和值 $ param = explode('=',$ params [$ i]); if($ param [0] =='titles'|| $ param [0] =='artists') $ clips [$ param [0]] = explode(',',$ PARAM [1]); } #获取玩家 $ player =''; foreach($ clip ['urls']为$ ukey => $ uvalue){ $ text =''; $ text。=(isset($ clips ['artists'] [$ ukey]))? $ clips ['artists'] [$ ukey]:''; $ text。=(isset($ clips ['artists'] [$ ukey])&& isset($ clips ['titles'] [$ ukey]))? ' - ':''; $ text。=(isset($ clips ['titles'] [$ ukey]))? $ clips ['titles'] [$ ukey]:''; if(!$ text)$ text = false; $ player。= wpaLink($ uvalue,$ text); } $ content = str_replace($ tag_matches [0] [$ key],$ player,$ content); } } 返回$ content; } #将字符串转换为unicode(隐藏mp3 URL)包括'php-utf8 / utf8.inc'; 函数wpaUnicode($ str){ $ uni = utf8ToUnicode(utf8_encode($ str)); $ output =''; foreach($ uni为$ value){ $ output。='\ u'。 str_pad(dechex($ value),4,'0',STR_PAD_LEFT); } 返回$ output; } ## WP管理菜单功能wpa_menu(){ add_options_page('WPaudio选项','WPaudio','switch_themes',__ FILE__,'wpa_menu_page ); } 函数wpa_menu_page(){ global $ wpa_options; if($ _POST){#Checkboxes需要值 $ wpa_checkboxes =数组('wpa_pref_link_mp3','wpa_tag_audio','wpa_track_permalink' ); foreach($ wpa_checkboxes为$ value){ $ _POST [$ value] =(isset($ _ POST [$ value])&& $ _POST [$ value])? 1:0; } #现在处理并保存所有选项 foreach($ wpa_options as $ key => $ value){ if(isset($ _ POST [$ key])& ;&!is_null($ _ POST [$ key])&& $ _POST [$ key]!=='') $ wpa_options [$ key] = $ _POST [$ key]; } update_option('wpaudio_options',$ wpa_options); } wpaOptions(); ?> <! - wpa菜单开始 - > < div class =wrap> < h2> WPaudio选项< / h2> < form method =POSTaction => <?php wp_nonce_field('update-options'); ?> < div id =poststuffclass =metabox-holder> < div class =meta-box-sortables> < div class =postbox> < h3 class =hndle>< span>链接< / span>< / h3> < div class =inside> < ul> < li> WPaudio将始终使用< span style =font-family:Courier,Serif> wpaudio< / span>转换链接类。您也可以选择处理所有mp3链接。< / li> < li>< label for =wpa_pref_link_mp3>< input name =wpa_pref_link_mp3id =wpa_pref_link_mp3type =checkbox<?php if($ wpa_options ['wpa_pref_link_mp3']) echo'check =yes'; ?>> 转换所有mp3链接 - < span style =font-family:Courier,Serif>& lt; a href =http://domain.com/song.mp3& gt; Link& ; LT; / A&安培; GT;< /跨度>< /标签>< /锂> < / ul> < / div> < / div> < div class =postbox> < h3 class =hndle>< span>标签< / span>< / h3> < div class =inside> < ul> < li> WPaudio将始终转换< span style =font-family:Courier,Serif> [wpaudio]< / span>标签,但它也可以处理来自其他音频播放器的标签。< / li> < li>< label for =wpa_tag_audio>< input name =wpa_tag_audioid =wpa_tag_audiotype =checkbox<?php if($ wpa_options ['wpa_tag_audio']) echo'check =yes'; ?>> 处理音频播放器标签 - < span style =font-family:Courier,Serif> [audio:http://domain.com/song.mp3]< / span>< / label> < /锂> < / ul> < / div> < / div> < div class =postbox> < h3 class =hndle>< span>样式< / span>< / h3> < div class =inside> < ul> < li>< a href =#onclick =jQuery('。wpa_style_advanced')。css('display','block');>没有必要调整这些设置,但是点击此处查看高级选项。< / a>< / li> < / ul> < ul class =wpa_style_advancedstyle =display:none;> < li>(可选)自定义WPaudio的字体< / li> < li>< label for =wpa_style_text_font>< input type =textname =wpa_style_text_fontid =wpa_style_text_fontvalue =<?php echo $ wpa_options ['wpa_style_text_font' ];?>>字体< / label>< / li> < li>< label for =wpa_style_text_size>< input type =textname =wpa_style_text_sizeid =wpa_style_text_sizevalue =<?php echo $ wpa_options ['wpa_style_text_size' ];?>>字体大小< / label>< / li> < li>< label for =wpa_style_text_weight>< select name =wpa_style_text_weightid =wpa_style_text_weight> < option value =inherit<?php if($ wpa_options ['wpa_style_text_weight'] =='inherit')echo'selected'; ?>>继承< /选项> < option value =normal<?php if($ wpa_options ['wpa_style_text_weight'] =='normal')echo'selected'; ?>>正常< /选项> < option value =bold<?php if($ wpa_options ['wpa_style_text_weight'] =='bold')echo'selected'; ?>>粗体< /选项> < / select>字体粗细< / label>< / li> < li>< label for =wpa_style_text_letter_spacing>< input type =textname =wpa_style_text_letter_spacingid =wpa_style_text_letter_spacingvalue =<?php echo $ wpa_options ['wpa_style_text_letter_spacing' ];?>>字母间距< / label>< / li> < / ul> < ul class =wpa_style_advancedstyle =display:none;> < li>可选择自定义颜色(最常见的是3或6个字符< a href =http://en.wikipedia.org/wiki/Web_colors#Color_tabletarget =_ blank>十六进制代码< / a>。例如:< span style =font-family:Courier,Serif>#2244ff< / span>)< / li> < li>< label for =wpa_style_text_color>< input type =textname =wpa_style_text_colorid =wpa_style_text_colorvalue =<?php echo $ wpa_options ['wpa_style_text_color' ];?>大小= 7 >文字颜色< / label>< / li> < li>< label for =wpa_style_link_color>< input type =textname =wpa_style_link_colorid =wpa_style_link_colorvalue =<?php echo $ wpa_options ['wpa_style_link_color' ];?>大小= 7 >链接颜色< / label>< / li> < li>< label for =wpa_style_link_hover_color>< input type =textname =wpa_style_link_hover_colorid =wpa_style_link_hover_colorvalue =<?php echo $ wpa_options ['wpa_style_link_hover_color' ];?>大小= 7 >链接悬停颜色< / label>< / li> < li>< label for =wpa_style_bar_base_bg>< input type =textname =wpa_style_bar_base_bgid =wpa_style_bar_base_bgvalue =<?php echo $ wpa_options ['wpa_style_bar_base_bg' ];?>大小= 7 >条形基础背景< / label>< / li> < li>< label for =wpa_style_bar_load_bg>< input type =textname =wpa_style_bar_load_bgid =wpa_style_bar_load_bgvalue =<?php echo $ wpa_options ['wpa_style_bar_load_bg' ];?>大小= 7 >栏加载背景< / label>< / li> < li>< label for =wpa_style_bar_position_bg>< input type =textname =wpa_style_bar_position_bgid =wpa_style_bar_position_bgvalue =<?php echo $ wpa_options ['wpa_style_bar_position_bg' ];?>大小= 7 >栏位背景< / label>< / li> < / ul> < / div> < / div> < div class =postbox> < h3 class =hndle>< span>通知< / span>< / h3> < div class =inside> < ul> < li>我喜欢看谁在使用我的插件!请选择此选项以在发布包含播放器的帖子时启用通知,以便我可以查看您的网站。您的博客甚至可能会出现在WPaudio.com上。 !感谢和LT; /锂> < li>< label for =wpa_track_permalink>< input name =wpa_track_permalinkid =wpa_track_permalinktype =checkbox<?php if($ wpa_options ['wpa_track_permalink']) echo'check =yes'; ?>> 允许WPaudio通知< / label>< / li> < / ul> < / div> < / div> < / div> < / div> < p class =submit> < input class =button-primarytype =submitvalue =Save Changes> < / p> < / form> < / div> <! - wpa菜单结束 - > <?php } ## WP新帖子 - 添加ping如果包含wpaudio 函数wpaPostNew($ id){ $ post = get_post($ ID); if(strpos(strtolower($ post-> post_content),'wpaudio')!== false){ $ permalink = rawurlencode(get_permalink($ id)); if(function_exists('curl_init')&& function_exists('curl_setopt')&& function_exists('curl_exec')&& function_exists('curl_close')){ $ ch = curl_init(http://wpaudio.com/t/?url_post=$permalink); curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1); curl_setopt($ ch,CURLOPT_HEADER,0); curl_exec($ ch); curl_close($ ch); } } } ?> 解决方案 如果你至少在IE8上,开发者工具很有帮助。他们在IE9中更好。只要您打开了开发人员控制台,就可以使用 console.log 语句来帮助查找代码所在的行。一旦完成,请小心删除 - console.log 会破坏IE 。我有预感,这是导致问题的主要原因。 Fiddler 应该有助于向您显示仍在等待的网络请求,网络选项卡 / p> Update: The issue seems to be that due to the JavaScript that was written to acccomodate a problem with Firefox/flash, the program is now trying to play html5 in IE, which isn't working for IE 8 and earlier. However, if I put a javascript based html5 link in the header http://html5media.info/, the html5 players work in IE 8 but not in any workable way. All the players show at once and start playing automatically. Note, all my students are in Asia so the game sort of has to work in IE 8...I made a game using jQuery/JavaScript for learners of English as a Second language at game here. It works in Chrome, Firefox and Safari, but not Internet Explorer. I don't know how to figure out the problem in I.E., but it seems like a pretty simple javascript problem that the cross-browser compatability of jQuery shouldn"t have a problem with, unless my code is so bad that I've screwed it up somehow (note that I am a relative newbie)The game uses 16 different audio recordings, so there are 16 different audio players. However, each audio player is hidden using css display: noneand then made to reappear with .css('display', 'block');but in IE it's not workingUsing JavaScript, I randomly select a number from 1 to 16 and then make one of the audio players visible based on that. It all happens when you click "start" on the game"s home page. However, in I.E., the audio player doesn"t show when I click start. This seems like a fairly basic JavaScript issue that I would have thought jQuery wouldn"t have cross-browser issues with, Note, other parts of the JavaScript appear to work in IE. For example, if you click one of the letters at the bottom of the game, it tells you whether your guess was right or wrong (based on the audio you"re supposed to hear).I also noticed that in I.E. the page takes a heck of a long time to load (5 minutes later, It still says 16 items remaining at the bottom). I assume those might be the audio players. In other browswers, that doesn't happen.It's very important for me that the game work in IE because the students I made it for are in Japan, and most of them use IECan anyone help me debug this in IE or give me an idea how to debug it in IE?This is the code that is supposed to make the audio player appear. Depending on whether browser uses Flash or HTML5 (which is detected with the line if ($('#ONE').length) ), jQuery then either uses "show" or .css('display', 'block') to make the audio player appear. Assuming IE is choosing flash, then it is using .css('display', 'block')to make the audio player appear (unsuccessfully)jQuery to make audio player appearfunction test() { $(".start").click(function() { ran = getRandom(myArray, true); if ($('#ONE').length) { $( '#' + ran ).show(); } else { $('#f-' + ran).css('display', 'block'); } });Update, this is the PHP file from the audio plugin## WPaudio version$wpa_version = '3.1';## Pre-2.6 compatibility (from WP codex)if ( ! defined( 'WP_CONTENT_URL' ) ) define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );if ( ! defined( 'WP_CONTENT_DIR' ) ) define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );if ( ! defined( 'WP_PLUGIN_URL' ) ) define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );if ( ! defined( 'WP_PLUGIN_DIR' ) ) define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );if ( ! defined( 'WPAUDIO_URL' ) ) define( 'WPAUDIO_URL', WP_PLUGIN_URL . '/wpaudio-mp3-player' );## Get WPaudio's options from DB (or create them if not found)$wpa_options = wpaOptions();## WP handlers - add WPaudio processing at necessary events# If it's not an admin page, get everything for the playerif ( !is_admin() ) { # Calling scripts add_action('init', 'wpaLibraries'); # Add header action to include CSS and JS vars add_action('wp_head', 'wpaHead'); # Add shortcode for WPaudio player add_shortcode('wpaudio', 'wpaShortcode'); # Add filter for shortcode in excerpt and widgets add_filter('the_excerpt', 'do_shortcode'); add_filter('widget_text', 'do_shortcode'); # Add filter for non-shortcode substitutes (including excerpts and widgets) if ($wpa_options['wpa_tag_audio']) { add_filter('the_content', 'wpaFilter'); add_filter('the_excerpt', 'wpaFilter'); add_filter('widget_text', 'wpaFilter'); }}# Add adminadd_action('admin_menu', 'wpa_menu');# Add trackif ($wpa_options['wpa_track_permalink']) add_action('publish_post', 'wpaPostNew');function wpaOptions(){ ## WPA options and defaults global $wpa_version; $wpa_options = Array( 'wpa_version' => $wpa_version, 'wpa_pref_link_mp3' => 0, 'wpa_tag_audio' => 0, 'wpa_track_permalink' => 1, 'wpa_style_text_font' => 'Sans-serif', 'wpa_style_text_size' => '18px', 'wpa_style_text_weight' => 'normal', 'wpa_style_text_letter_spacing' => 'normal', 'wpa_style_text_color' => 'inherit', 'wpa_style_link_color' => '#24f', 'wpa_style_link_hover_color' => '#02f', 'wpa_style_bar_base_bg' => '#eee', 'wpa_style_bar_load_bg' => '#ccc', 'wpa_style_bar_position_bg' => '#46f', 'wpa_style_sub_color' => '#aaa' ); if ( $wpa_options_db = get_option( 'wpaudio_options' ) ) { foreach ( $wpa_options as $key => $value ) { if ( isset($wpa_options_db[$key]) ) { $wpa_options[$key] = $wpa_options_db[$key]; } } } else { # Get legacy options and remove if they exist if ( get_option('wpa_tag_audio') ) { foreach ($wpa_options as $key => $value) { $wpa_option_old_db = get_option($key); if ( $wpa_option_old_db !== false && $wpa_option_old_db !== '' ) { $wpa_options[$key] = $wpa_option_old_db; } delete_option($key); } } # Create wpaudio_options add_option('wpaudio_options', $wpa_options, '', 'no'); //update_option('wpaudio_options', $wpa_options); } return $wpa_options;}## Built-in librariesfunction wpaLibraries(){ global $wpa_version; //wp_deregister_script( 'jquery' ); //wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js', '1.4.3' ); if ( version_compare( get_bloginfo( 'version' ), '2.8', '>=' ) ) { if ( WP_DEBUG === false ) { wp_register_script( 'wpaudio', WPAUDIO_URL . '/wpaudio.min.js', Array('jquery'), $wpa_version, true ); } else { wp_register_script( 'wpaudio', WPAUDIO_URL . '/wpaudio.js', Array('jquery'), $wpa_version, true); } wp_enqueue_script( 'wpaudio' ); } else { wp_enqueue_script('jquery'); add_action('wp_footer', 'wpaFooterForOldVersions'); }}## WPaudio style, jQuery, SWFObjectfunction wpaHead(){ global $wpa_options; # Put all styles into the _wpaudio settings object $style = ''; foreach ( $wpa_options as $key => $value ) { $exploded = explode('_', $key, 3); if ( $exploded[1] == 'style' ) { $style .= $exploded[2] . ":'$value',"; } } $style = trim( $style, ',' ); $style = '{' . $style . '}'; # Common JS $wpa_pref_link_mp3 = ($wpa_options['wpa_pref_link_mp3']) ? 'true' : 'false'; $head = "<script type='text/javascript'>/* <![CDATA[ */ var _wpaudio = {url: '" . WPAUDIO_URL . "', enc: {}, convert_mp3_links: $wpa_pref_link_mp3, style: $style}; /* ]]> */</script>"; echo $head;}function wpaFooterForOldVersions() { echo '<script type="text/javascript" src="' . WPAUDIO_URL . '/wpaudio.min.js"></script>';}# Used only for wpaudio shortcode tagsfunction wpaShortcode($atts){ # Convert shortcodes to WPaudio player depending on settings extract(shortcode_atts(Array( 'url' => false, 'text' => false, 'dl' => true, 'autoplay' => false ), $atts)); # If no url, return with nothing if (!$url) return; # Get player HTML and JS return wpaLink($url, $text, $dl, $autoplay);}# Make WPA linkfunction wpaLink($url, $text = false, $dl = true, $autoplay = false) { $id = uniqid('wpaudio-'); $class = 'wpaudio'; $html = ''; # Handle dl URLs and no dl players if ($dl == '0') { $js_url = wpaUnicode($url); $href = '#'; $class .= ' wpaudio-nodl'; } elseif (is_string($dl)) { $js_url = wpaUnicode($url); $href = $dl; } else { $href = $url; } if (isset($js_url)) { $class .= ' wpaudio-enc'; $html .= "<script type='text/javascript'>_wpaudio.enc['$id'] = '$js_url';</script>"; } # Handle blank text if (!$text) { $text = basename($url); $class .= ' wpaudio-readid3'; } # Autoplay if ($autoplay == '1') { $class .= ' wpaudio-autoplay'; } $html .= "<a id='$id' class='$class' href='$href'>$text</a>"; return $html;}# Used for audio tagsfunction wpaFilter($content){ ## Convert audio tags and links to WPaudio player depending on settings $tag_regex = '/\[audio:(.*?)\]/'; $tag_match = preg_match_all($tag_regex, $content, $tag_matches); # Replace audio tags with player links if ($tag_match){ foreach ($tag_matches[1] as $key => $value){ # This is one tag, first get parameters and URLs $params = explode('|', $value); $clips = Array('urls' => Array(), 'titles' => Array(), 'artists' => Array()); $clips['urls'] = explode(',', $params[0]); # Process extra parameters if they exist for ($i=1; $i<count($params); $i++) { # Get the parameter name and value $param = explode('=', $params[$i]); if ($param[0] == 'titles' || $param[0] == 'artists') $clips[$param[0]] = explode(',', $param[1]); } # Get player(s) $player = ''; foreach ($clips['urls'] as $ukey => $uvalue) { $text = ''; $text .= (isset($clips['artists'][$ukey])) ? $clips['artists'][$ukey] : ''; $text .= (isset($clips['artists'][$ukey]) && isset($clips['titles'][$ukey])) ? ' - ' : ''; $text .= (isset($clips['titles'][$ukey])) ? $clips['titles'][$ukey] : ''; if (!$text) $text = false; $player .= wpaLink($uvalue, $text); } $content = str_replace($tag_matches[0][$key], $player, $content); } } return $content;}# Convert string to unicode (to conceal mp3 URLs)include 'php-utf8/utf8.inc';function wpaUnicode($str){ $uni = utf8ToUnicode(utf8_encode($str)); $output = ''; foreach ($uni as $value){ $output .= '\u' . str_pad(dechex($value), 4, '0', STR_PAD_LEFT); } return $output;}## WP admin menufunction wpa_menu() { add_options_page('WPaudio Options', 'WPaudio', 'switch_themes', __FILE__, 'wpa_menu_page');}function wpa_menu_page() { global $wpa_options; if ($_POST) { # Checkboxes need values $wpa_checkboxes = Array( 'wpa_pref_link_mp3', 'wpa_tag_audio', 'wpa_track_permalink' ); foreach ($wpa_checkboxes as $value) { $_POST[$value] = (isset($_POST[$value]) && $_POST[$value]) ? 1 : 0; } # Now process and save all options foreach ($wpa_options as $key => $value) { if (isset($_POST[$key]) && !is_null($_POST[$key]) && $_POST[$key] !== '') $wpa_options[$key] = $_POST[$key]; } update_option('wpaudio_options', $wpa_options); } wpaOptions(); ?><!-- wpa menu begin --><div class="wrap"><h2>WPaudio Options</h2><form method="POST" action=""><?php wp_nonce_field('update-options'); ?><div id="poststuff" class="metabox-holder"> <div class="meta-box-sortables"> <div class="postbox"> <h3 class="hndle"><span>Links</span></h3> <div class="inside"> <ul> <li>WPaudio will always convert links with the <span style="font-family: Courier, Serif">wpaudio</span> class. You optionally handle ALL mp3 links too.</li> <li><label for="wpa_pref_link_mp3"><input name="wpa_pref_link_mp3" id="wpa_pref_link_mp3" type="checkbox" <?php if ($wpa_options['wpa_pref_link_mp3']) echo ' checked="yes"'; ?>> Convert all mp3 links - <span style="font-family: Courier, Serif"><a href="http://domain.com/song.mp3">Link</a></span></label></li> </ul> </div> </div> <div class="postbox"> <h3 class="hndle"><span>Tags</span></h3> <div class="inside"> <ul> <li>WPaudio will always convert <span style="font-family: Courier, Serif">[wpaudio]</span> tags, but it can also handle tags from other audio players.</li> <li><label for="wpa_tag_audio"><input name="wpa_tag_audio" id="wpa_tag_audio" type="checkbox" <?php if ($wpa_options['wpa_tag_audio']) echo ' checked="yes"'; ?>> Handle Audio Player tags - <span style="font-family: Courier, Serif">[audio:http://domain.com/song.mp3]</span></label></li> </ul> </div> </div> <div class="postbox"> <h3 class="hndle"><span>Style</span></h3> <div class="inside"> <ul> <li><a href="#" onclick="jQuery('.wpa_style_advanced').css('display', 'block');">It's not necessary to adjust these settings, but click here for advanced options.</a></li> </ul> <ul class="wpa_style_advanced" style="display: none;"> <li>Optionally customize WPaudio's font</li> <li><label for="wpa_style_text_font"><input type="text" name="wpa_style_text_font" id="wpa_style_text_font" value="<?php echo $wpa_options['wpa_style_text_font']; ?>"> Font face</label></li> <li><label for="wpa_style_text_size"><input type="text" name="wpa_style_text_size" id="wpa_style_text_size" value="<?php echo $wpa_options['wpa_style_text_size']; ?>"> Font size</label></li> <li><label for="wpa_style_text_weight"><select name="wpa_style_text_weight" id="wpa_style_text_weight"> <option value="inherit" <?php if ($wpa_options['wpa_style_text_weight'] == 'inherit') echo ' selected'; ?>>Inherit</option> <option value="normal" <?php if ($wpa_options['wpa_style_text_weight'] == 'normal') echo ' selected'; ?>>Normal</option> <option value="bold" <?php if ($wpa_options['wpa_style_text_weight'] == 'bold') echo ' selected'; ?>>Bold</option> </select> Font weight</label></li> <li><label for="wpa_style_text_letter_spacing"><input type="text" name="wpa_style_text_letter_spacing" id="wpa_style_text_letter_spacing" value="<?php echo $wpa_options['wpa_style_text_letter_spacing']; ?>"> Letter spacing</label></li> </ul> <ul class="wpa_style_advanced" style="display: none;"> <li>Optionally customize colors (Most commonly 3 or 6 character <a href="http://en.wikipedia.org/wiki/Web_colors#Color_table" target="_blank">hex codes</a>. For example: <span style="font-family: Courier, Serif">#2244ff</span>)</li> <li><label for="wpa_style_text_color"><input type="text" name="wpa_style_text_color" id="wpa_style_text_color" value="<?php echo $wpa_options['wpa_style_text_color']; ?>" size="7"> Text color</label></li> <li><label for="wpa_style_link_color"><input type="text" name="wpa_style_link_color" id="wpa_style_link_color" value="<?php echo $wpa_options['wpa_style_link_color']; ?>" size="7"> Link color</label></li> <li><label for="wpa_style_link_hover_color"><input type="text" name="wpa_style_link_hover_color" id="wpa_style_link_hover_color" value="<?php echo $wpa_options['wpa_style_link_hover_color']; ?>" size="7"> Link hover color</label></li> <li><label for="wpa_style_bar_base_bg"><input type="text" name="wpa_style_bar_base_bg" id="wpa_style_bar_base_bg" value="<?php echo $wpa_options['wpa_style_bar_base_bg']; ?>" size="7"> Bar base background</label></li> <li><label for="wpa_style_bar_load_bg"><input type="text" name="wpa_style_bar_load_bg" id="wpa_style_bar_load_bg" value="<?php echo $wpa_options['wpa_style_bar_load_bg']; ?>" size="7"> Bar load background</label></li> <li><label for="wpa_style_bar_position_bg"><input type="text" name="wpa_style_bar_position_bg" id="wpa_style_bar_position_bg" value="<?php echo $wpa_options['wpa_style_bar_position_bg']; ?>" size="7"> Bar position background</label></li> </ul> </div> </div> <div class="postbox"> <h3 class="hndle"><span>Notification</span></h3> <div class="inside"> <ul> <li>I love seeing who's using my plugin! Please select this option to enable a notification when a post containing the player is published so I can come check out your site. Your blog may even be featured on WPaudio.com. Thanks!</li> <li><label for="wpa_track_permalink"><input name="wpa_track_permalink" id="wpa_track_permalink" type="checkbox" <?php if ($wpa_options['wpa_track_permalink']) echo ' checked="yes"'; ?>> Allow WPaudio notification</label></li> </ul> </div> </div> </div></div><p class="submit"> <input class="button-primary" type="submit" value="Save Changes"></p></form></div><!-- wpa menu end --><?php}## WP new post - add ping if contains wpaudiofunction wpaPostNew($id) { $post = get_post($id); if (strpos(strtolower($post->post_content), 'wpaudio') !== false) { $permalink = rawurlencode(get_permalink($id)); if (function_exists('curl_init') && function_exists('curl_setopt') && function_exists('curl_exec') && function_exists('curl_close')) { $ch = curl_init("http://wpaudio.com/t/?url_post=$permalink"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_exec($ch); curl_close($ch); } }}?> 解决方案 If you're on at least IE8, the developer tools are helpful. They're even better in IE9. As long as you've got the developer console open, sprinkling console.log statements around can help find what line(s) your code is borking on. Be careful to remove then once you're done though - console.log breaks IE if you have the developer window closed.I've got a hunch this is the main cause of your problems. Fiddler should help show you what network requests are still waiting, as will the network tab in the IE9 developer tools 这篇关于jQuery:跨浏览器问题 - 调试Internet Explorer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-14 21:11