gpt4 book ai didi

javascript - Drupal Jquery 不适用于正文内容

转载 作者:行者123 更新时间:2023-11-28 01:43:06 43 4
gpt4 key购买 nike

我的 drupal 主体有以下代码,其 php 代码文本格式:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

<img id="thisImg" alt="img" src="http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/ads1.jpg"/>
<script type="text/javascript">
var myImage = new Array();
ctr = 0;

$(function(){
<?php
$log_directory = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/';
foreach(glob($log_directory.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory2 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery2/';
foreach(glob($log_directory2.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory3 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery3/';
foreach(glob($log_directory3.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory4 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery4/';
foreach(glob($log_directory4.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory5 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery5/';
foreach(glob($log_directory5.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory6 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery6/';
foreach(glob($log_directory6.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory7 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery7/';
foreach(glob($log_directory7.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory8 = 'http://localhost/fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery8/';
foreach(glob($log_directory8.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage.push("<?php echo $filename?>");
ctr =ctr +1;
<?php
}
?>
console.log(myImage);
var thisId=0;
window.setInterval(function(){
$('#thisImg').attr('src',myImage[thisId]);
thisId++; //increment data array id
if (thisId==ctr) thisId=0; //repeat from start
},2000);
});
</script>

当我尝试单独在 php 文件中运行此代码时。

/var/www/unplay/trytoplay.php

效果很好。但是当我尝试将其写在 drupal 主体中时。它不起作用。然后我尝试运行我的控制台,它显示:

Uncaught TypeError: Object [object Object] has no method 'tinyNav' main-menu.jsmxywgd:85
Uncaught TypeError: Object [object Object] has no method 'cycle'

我尝试安装tinyNav,但没有任何反应。感谢您的帮助。

最佳答案

尝试更新你的jquery。您可以引用这个链接https://drupal.org/project/jquery_update

我在没有 jquery 的情况下尝试了这个。

<img id="thisImg" alt="img" src="../fastcat.com.ph/sites/all/themes/impact_theme/images/ads1.jpg"/>
<script type="text/javascript">
var dataArray=new Array();
dataArray[0]="images/img1.png";
dataArray[1]="images/img2.png";
dataArray[2]="images/img3.png";
dataArray[3]="images/img0.png";

var myImage = new Array();
ctr = 0;

<?php
$log_directory = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/';
foreach(glob($log_directory.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory2 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery2/';
foreach(glob($log_directory2.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory3 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery3/';
foreach(glob($log_directory3.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory4 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery4/';
foreach(glob($log_directory4.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory5 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery5/';
foreach(glob($log_directory5.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory6 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery6/';
foreach(glob($log_directory6.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory7 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery7/';
foreach(glob($log_directory7.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
<?php
$log_directory8 = '../fastcat.com.ph/sites/all/themes/impact_theme/images/images/large/gallery8/';
foreach(glob($log_directory8.'{*.gif,*.jpg,*.png,*.JPG,*GIF,*.PNG}',GLOB_BRACE) as $filename) {
?>
myImage[ctr] = "<?php echo $filename?>";
ctr =ctr +1;
<?php
}
?>
var thisId=0;
setInterval(function(){
document.getElementById("thisImg").src=myImage[thisId];
// document.write(myImage[thisId]);
thisId++; //increment data array id
if (thisId==ctr) thisId=0; //repeat from start
},2000);
</script>

关于javascript - Drupal Jquery 不适用于正文内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20644761/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com