-2

Well, the title may be sounds easy, but what i want is to do the same thing from browser address bar (my page contains many videos ). i tried

   javascript:videoelement=document.getElementById("vid1");videoelement.pause();

It doesn't works anyway.

suppose my code is

<html>
<body>
<embed src="https://myaudio.mp3" autoplay="false" height="100" width="300">
</body>
</html>

how can i pause/paly the player?

javascript:document.getElementsByTagName("embed").pause();   

^^^ not working

Yuvifan
  • 67
  • 7

3 Answers3

2

Remove the # from the element name like so:

javascript:videoelement=document.getElementById("vid1");videoelement.pause();

You are already using the getElementById function so you don't need it.

Alex Pan
  • 4,341
  • 8
  • 34
  • 45
0

You are using a jQuery/CSS ID selector when what you wanted was using vanilla javascript.

You are trying to select an element with ID "#vid1", such as: <video id="#vid1">

Just remove the "#" from getElementById.

gcandal
  • 937
  • 8
  • 23
0

HTML Audio/Video DOM pause() Method:

The play() method starts playing the current audio or video.

Tip: Use the pause() method to pause the current audio/video.

Mohammed Akdim
  • 2,223
  • 1
  • 13
  • 21