HighSlide iframe中的jQuery不起作用

时间:2014-04-20 18:06:25

标签: javascript php jquery iframe highslide

HighSlide iFrame弹出窗口中,简单 jQuery无法正常工作 ....

好的......这就是我所拥有的:

<html>
<head>
     <title>test</title>
     <link rel="stylesheet" type="text/css" href="http://cdn.example.com/plugins/highslide/highslide.css" />
    <!--[if lt IE 7]>
        <link rel="stylesheet" type="text/css" href="http://cdn.example.com/plugins/highslide/highslide-ie6.css" />
    <![endif]-->
    <script async src='//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'></script>
</head>
<body>
     <a href='update.php' onclick="return hs.htmlExpand(this, { objectType: 'iframe', allowWidthReduction: true } )">update</a>

      <script type="text/javascript" src="http://cdn.example.com/plugins/highslide/highslide-full.js"></script>
    <script type="text/javascript" src="http://cdn.example.com/plugins/highslide/highslide.config.js" charset="utf-8"></script>
</body>
</html>

以下是 update.php

的代码
<?php
  echo "<head>";
   echo "<script async src='//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js'></script>";
  echo "</head>";
  echo "<body>";
     ?>
<script>
$(document).ready( function(){
    $('#isMain').click( function(){
       if(this.checked){
          $('#subCats').hide();
       }else{
          $('#subCats').show();
       }
    });
});
</script>
     <?php
     echo "<form action='' method='post' role='form'>";
          echo "<input type='checkbox' name='isMain' id='isMain'> Is Main Category?<br>";
          echo "<select name='subCats' id='subCats'>";
               echo "<option value='noway'>--SELECT--</option>";
               echo "<option value='1'>Games</option>";
               echo "<option value='2'>Music</option>";
          echo "</select>";
     echo "</form>";
  echo "</body>";
?>

但jQuery Hide Show有时工作正常,有时候不起作用......这里有什么问题???

1 个答案:

答案 0 :(得分:0)

jQuery(或任何其他JavaScript)在使用Highslide iframe objectType弹出窗口打开的页面中工作 - objectType: 'iframe' - 因为iframe弹出窗口打开链接页面的方式与编码完全相同。 />
使用您的代码进行演示:http://jsfiddle.net/roadrash/rX4Bc/
iframe弹出窗口中使用的页面:http://jsfiddle.net/roadrash/UWq3c/