点击页面上的链接加载javascript [英] Click link on page load javascript
问题描述
我希望视频能够在页面加载时开始播放。我试着编写一个脚本,在页面加载时会点击播放按钮链接,但它不起作用。那个剧本是
I'd like a video to start playing on page load. I tried to write a script that on page load will click the 'play' button link, but it is not working. That script is
<script>
$(document).on('ready', function () {
$(getElementByClass('.mSIcon.mSVideo')).trigger('click');
)};
</script>
播放按钮位于
$ b链接中$ b
为什么这不起作用?该网站是 http://smmcnyc.com/work/smmc/smmc1306/ [ ^ ]
我还需要要播放的视频,以及第一个视频结束后,第二个视频开始播放。知道如何解决这个问题吗?
The play button is in the link
Why is this not working? The site is http://smmcnyc.com/work/smmc/smmc1306/[^]
I also need the videos to cycle, and after the first video ends, for the second video to start. Any idea how to solve this as well?
推荐答案
( document )。on(' ready', function (){
(document).on('ready', function () {
(getElementByClass(' .mSIcon.mSVideo'))。触发器(< span class =code-string>' click');
)};
< / script>
(getElementByClass('.mSIcon.mSVideo')).trigger('click'); )}; </script>
播放按钮位于
$ b链接中$ b
为什么这不起作用?该网站是 http://smmcnyc.com/work/smmc/smmc1306/ [ ^ ]
我还需要要播放的视频,以及第一个视频结束后,第二个视频开始播放。知道如何解决这个问题吗?
The play button is in the link
Why is this not working? The site is http://smmcnyc.com/work/smmc/smmc1306/[^]
I also need the videos to cycle, and after the first video ends, for the second video to start. Any idea how to solve this as well?
浏览器永远不会允许脚本定位从不同于其自身的源加载的元素。
The browser will never allow a script to target an element that is loaded from a different source than itself.
这篇关于点击页面上的链接加载javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!