You can’t control it if you embed it with an iframe. You have to use object embedding, like this:
<object id="ytplayer" style="height: 390px; width: 640px"> <param name="movie" value="http://www.youtube.com/v/8Ax-dAR3ABs?version=3&enablejsapi=1"> <param name="allowScriptAccess" value="always"> <embed id="ytplayer" src="http://www.youtube.com/v/8Ax-dAR3ABs?version=3&enablejsapi=1" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390"> </object>
The rest of your code should generally work after that, although it may need to be updated to say:
<a href="javascript:document.getElementById('ytplayer').stopVideo()">Play</a>
Also, have you seen the demo site? http://code.google.com/apis/youtube/youtube_player_demo.html
Related Posts:
- Is it possible to enqueue the Youtube API script or does it have to be inline?
- TypeError: res.status is not a function
- Failed to execute ‘postMessage’ on ‘DOMWindow’: https://www.youtube.com !== http://localhost:9000
- How to embed a youtube playlist with a sidebar
- How to embed an autoplaying YouTube video in an iframe?
- WP Rest API – How to get featured image
- Is it Possible to Extend WP Customize JS Methods?
- Show only images and videos in a wp.media window
- WordPress Rest API
- Preventing YouTube embeds loading multiple instances of player JS?
- Customizer JS API: Defining control settings
- Headless WordPress: How to authenticate front end requests?
- Customizer JS API: Adding Setting Dynamically Not Working
- Is there a client side API for handling transients or options?
- Customizer JS API: Adding a “dropdown-pages” control
- How to disable inline css styles generated by Gutenberg editor?
- WordPress customizer get control
- Get a default value of the Customizer setting using wp.customize API (JS)
- I am trying to add current logged in user to my zoho chat
- This page can’t load Google Maps correctly [closed]
- Customizer JS API: Defining active_callback for a section
- how to use nimble-API and Display data?
- create timestamp links to jump to specific times on rumble videos
- WordPress Guternberg Content For React Native
- youtube full screen on off permater code help for wordpress
- Show sections based on a control in WordPress Customizer using JS API
- I would like to retrive JSON value and display it in wordpress page or widget
- How do I add a class to Customizer preview based on class of Customizer control? (Customizer Javascript API)
- Get a default customizeAction text for a section using Customizer JS API
- Create new product with woocommerce REST API with javascript (clientside)?
- Anyway to disable the auto excerpt creation?
- How can I generate a rainbow circle using HTML5 canvas?
- Which equals operator (== vs ===) should be used in JavaScript comparisons?
- are there dictionaries in javascript like python?
- Jest spy on functionality
- Use a JSON array with objects with javascript
- Toggle show/hide on click with jQuery
- Client on Node.js: Uncaught ReferenceError: require is not defined
- jQuery .on(‘change’, function() {} not triggering for dynamically created inputs
- How to create a jQuery function (a new jQuery method or plugin)?
- How do you check if a variable is an array in JavaScript?
- Understanding React-Redux and mapStateToProps()
- What is the meaning of == $0 that is shown in inspect element of google chrome for the selected element [duplicate]
- How to get the browser to navigate to URL in JavaScript
- In angularjs we are having ng-disabled directive, why ng-enabled directive is not provided by the framework as we are having ng-show and ng-hide
- Send POST data using XMLHttpRequest
- querySelector vs. getElementById
- Google weather widget on my website
- How to generate a simple popup using jQuery
- How to convert an Object {} to an Array [] of key-value pairs in JavaScript
- Javascript versioning to avoid caching, difference in these practices?
- SyntaxError: Unexpected token o in JSON at position 1
- Fastest way to duplicate an array in JavaScript – slice vs. ‘for’ loop
- When is JavaScript synchronous?
- How to reset a form using jQuery with .reset() method
- Uncaught ReferenceError: Firebase is not defined
- Efficient way to implement Priority Queue in Javascript?
- How do you format a Date/Time in TypeScript?
- JavaScript function in href vs. onclick
- How to scroll to an element?
- getBoundingClientRect is not a function
- Jquery button click() function is not working
- Make iframe automatically adjust height according to the contents without using scrollbar?
- Uncaught ReferenceError: function is not defined with onclick
- Remove last item from array
- How do I check whether a checkbox is checked in jQuery?
- Failed to find a valid digest in the ‘integrity’ attribute for resource on a deployed emberjs application
- Cannot read property ‘getHostNode’ of null
- TypeError: Class extends value undefined is not a function or null
- Eslint: How to disable “unexpected console statement” in Node.js?
- How to get native javascript functions source code?
- Get the Highlighted/Selected text
- Video auto play is not working in Safari and Chrome desktop browser
- Replace all spaces in a string with ‘+’
- Uncaught ReferenceError: ga is not defined
- Getting or changing CSS class property with Javascript using DOM style
- How to close a window using jQuery
- Javascript- Multiplying 2 numbers and return number
- What does the $() function do in JavaScript?
- How to change href of tag on button click through javascript
- How to only enqueue block javascript on the frontend when its needed [duplicate]
- Correct place to register and enqueue scripts
- How to replace a javascript select box onchange event to a form submit action?
- Add tinymce dynamically via Javascript
- How to Add Javascript Only When a Function Exists?
- TypeError: window.tinyMCE.execInstanceCommand is not a function
- How to load javascript file on homepage in WordPress in order?
- event/callback on block update?
- wordpress 4.4 upgrade visual editor bullets select for not selected elements
- Script to Automatically Advance to the Next Page of a Paginated Post
- Gutenberg consume wp-json data and reflect in frontend the content
- How can I get user data into a javascript object?
- WordPress load-scripts.php not loading
- Removing admin javascript
- Can I get the user name in JavaScript?
- Landing function through URL
- Custom JS doesn’t work after 4.9.9 update [closed]
- How to load JavaScript modules with script_loader_tag hook?
- How to securely set dynamic HTML content with JavaScript?
- Astra Mobile Cart Drawer is blank on home page