homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

Anchors and Autoplay Video
anchor to another page and autoplay

Msg#: 4680626 posted 9:49 pm on Jun 17, 2014 (gmt 0)

To those of you who are really good at writing code this is probably a simple question. I have created a Button on my homepage that directs you to another page and to a particular spot on that page. I did this by making the HREF for the Button an anchor. Currently the anchor takes you to a spot just above a video (the Button is intended to direct you to said video).

Is it possible to have the anchor also start playing the video when the Button is clicked?
Currently I have set the video's embedded code to auto play, but I do not want the video to auto play if you access the page by any other means. I only want it to auto play if you click the Button, but otherwise I'd like a user to have to manually start the video. So can I code the Button to include an action like "play"? Again, my Button currently does not point to the video, it points to an anchor just above the video.

if you'd like to see the website, it is <snip> and the Button I'm talking about is "Go To Video"

*I capitalized the word "Button" throughout to make clear that I am consistently referring to the same button.

[edited by: incrediBILL at 12:17 am (utc) on Jun 18, 2014]
[edit reason] URls removed. No Site Reviews. Please see forum charter and TOS. [/edit]



Msg#: 4680626 posted 9:51 pm on Jun 17, 2014 (gmt 0)

If it helps, the code I currently have for the button is below:

<a href="/project-discovery/#IntroVideo"/class="arrow_btn">Go to Video</a><br>


WebmasterWorld Administrator 5+ Year Member Top Contributors Of The Month

Msg#: 4680626 posted 1:22 am on Jun 18, 2014 (gmt 0)

<a href="/project-discovery/#IntroVideo"/class="arrow_btn">Go to Video</a><br>
This link isn't quite right, is this:
a typo or an exact copy of what you are using?

WebmasterWorld Senior Member fotiman us a WebmasterWorld Top Contributor of All Time 5+ Year Member

Msg#: 4680626 posted 4:10 pm on Jun 18, 2014 (gmt 0)

Welcome to WebmasterWorld!
As not2easy pointed out, it looks like you have an extra slash in that line.

In any case, on the page where your embed video is located, you'll want some JavaScript that runs when the window.onload event fires. That script should check to see if window.location.hash === "#IntroVideo", and if so, autostart the video. This will not prevent someone from navigating directly to the the "/project-discover/#IntroVideo" page without pushing the button, but it will only autostart the video if the #IntroVideo is in the url, which I suspect is what you're trying to achieve.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved