我最近在使用wordpress,插件,它已经到了最后阶段,剩下的就是跨浏览器兼容性,问题是为什么短代码无法正常使用IE。以下是我的代码:
<?php
/*
Plugin Name: Taggr
Plugin URI: http://example.com/wordpress-plugins/my-plugin
Description: Premium plugin for image and photo tagging
Version: 1.0
Author: Tee Kai Yang
Author URI: http://wrox.com
License: GPLv2
*/
add_action('init', 'register_tagging_post');
function register_tagging_post(){
wp_enqueue_script('jquery2','http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
}
$taggrArr = array();
//add shortcode
add_shortcode('taggr' , 'shortcode_func');
function shortcode_func($attr){
global $wpdb;
global $post;
$plugin_url = plugins_url();
$taggrImageId = $attr['id'];
$imageBaseName = $attr['name'];
global $taggrArr;
if(!isset($taggrArr["post". $post -> ID])){
$taggrArr["post". $post -> ID] = 0;
}
$taggrArr["post". $post -> ID]++;
$sql2 = "SELECT * FROM wp_taggr3 WHERE post_id = $taggrImageId";
$rows_retrieve2 = $wpdb -> get_results($sql2, ARRAY_A);
echo "<div style='position: relative;' id= 'wow".$post -> ID."'>";
echo "<img src='http://www.billboard.com/files/styles/promo_650/public/stylus/2297459-katy-perry-outrageous-outfits-617-409.jpg' id ='img" . $taggrArr["post". $post -> ID]. "post" .$post -> ID . "'>";
echo "<div style='position: absolute;' id= 'wiw".$post -> ID. "taggr". $taggrArr["post". $post -> ID]."'></div>";
?>
<script>
function woo1(){
var imageDisplay = document.getElementById('<?php echo "img" . $taggrArr["post". $post -> ID]. "post" . $post -> ID; ?>');
var polyShapeCount;
var localTaggrCount = <?php echo $taggrArr["post". $post -> ID]; ?>;
$(imageDisplay).load(function(){
alert(this.id);
var imageDisplayShadow = document.getElementById('<?php echo "wiw" . $post -> ID; ?>taggr' + localTaggrCount);
imageDisplayShadow.style.width = imageDisplay.width + "px";
imageDisplayShadow.style.height = imageDisplay.height + "px";
imageDisplayShadow.style.top = "0px";
imageDisplayShadow.style.left = "0px";
var imageDisplayShadow1 = document.createElementNS("http://www.w3.org/2000/svg", "svg");
imageDisplayShadow1.style.width = "100%";
imageDisplayShadow1.style.height = "100%";
imageDisplayShadow1.style.top = "0px";
imageDisplayShadow1.style.left = "0px";
imageDisplayShadow1.setAttribute("viewBox", "0 0 100 100");
imageDisplayShadow1.setAttribute("preserveAspectRatio", "none");
imageDisplayShadow.appendChild(imageDisplayShadow1);
<?php
foreach($rows_retrieve2 as $row_retrieve2){
if($row_retrieve2['tag_key'] == "tag"){
$tag_value = unserialize($row_retrieve2['tag_value']);
if($tag_value['shape'] == "square"){
?>
var createTag = document.createElement("div");
<?php
}
}
}
?>
});
}
woo1();
</script>
<?php
echo "</div>";
}
?>
这是问题所在的部分,我用taggr短代码创建了4个不同的帖子,通过查看这段代码,页面应该提醒四种不同类型的图片ID,我在firefox上尝试过,chrome一切正常,但是在Internet Explorer中,它只显示3个警报,任何人都可以告诉我为什么??