简体   繁体   English

我如何在jQuery中的页面加载时播放动画,以便它播放index.php而不播放other_page.php

[英]How can I play an animation on page load in jQuery so that it plays for index.php but not e.g. other_page.php

I want to play an animation on page load but only for my index.php and not for every other page of my website. 我想在页面加载时播放动画,但只对我的index.php播放,而不对网站的其他页面播放。

Is there something like this for jQuery: jQuery是否有类似这样的内容:

$('index.php').ready(function());

?

If not how can I achieve the desired effect? 如果没有,我怎么能达到预期的效果?

Just put your jQuery code in index.php page only using any of the following jquery load functions. 只需使用以下任何jquery加载函数将jQuery代码放入index.php页面即可。

$(window).load(function(){...});

or 要么

$(document).ready(function(){...});

or 要么

$('body').onload(function(){...});

by this your animation will run only on index.php page and not any other page. 这样,您的动画将仅在index.php页面上运行,而不在其他任何页面上运行。

Hope this will solve your problem. 希望这能解决您的问题。

You can check the url with Javascript and then fire your function to play 您可以使用Javascript检查网址,然后触发您要播放的功能

if(
window.location.href=="address to check"
)
 your_function();
{
/* some code to load */
}else{
document.write('<div>testing my super loaded div code sample</div>')
}
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 kotlin JS 测试 UI? (例如在页面上有一个元素) - How can I test UI with kotlin JS? (e.g. have an element on a page) 如何在PHP中使用Ajax从网站(例如IMDB)中获取数据 - How can I fetch data from a website (e.g. IMDB ) using Ajax in PHP 如果使用jquery进行会话检查在后台失败,如何重定向index.php页面? - How to redirect index.php page if session checking with jquery fails in the background? Facebook应用登陆页面为index.php - Facebook app landing page to be index.php 页面重新加载回到index.php - Page reload goes back to index.php 如何在特定的JavaScript代码中加载外部HTML页面? 例如,在JS函数中 - How to load an external HTML page within a specific JavaScript code? E.g. Within a JS function GSAP和jQuery:在下一页加载时播放动画 - GSAP and jQuery: play animation on the next page load URL 上的加载页面搜索仅适用于 index.php 表单提交。 -JS - Load page on URL search works only from index.php form submission. -JS 如何通过动画动态加载页面元素(即图像)? - How to dynamically load in page elements (i.e. images) with an animation? 捕获页面加载后创建的<img>标记的img加载错误(例如,通过AJAX) - Catching img load error for <img> tags created after page load (e.g. via AJAX)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM