SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Now available in Orange Tijmen's Avatar
    Join Date
    Jul 2004
    Location
    The Netherlands
    Posts
    1,469
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    movie.SetAttribute is not a function

    I have just started with javascript and have made the following simple function. Inside a iframe, based on which link is clicked one div becomes hidden while the other one shows up. The video window should be playing a video after someone pushed the button.

    That worked fine on the mac, but not on the PC. When i tested it on IE6 the movie started playing while the movie wasn't even visible. So i came up with having the <embed> in the hidden div, but without any real info. So just src="" etc. This should change when the video button is clicked, unfortunately it doesn't really work.

    It keeps saying "movie.SetAttribute is not a function", i found out that the document.getElementById("movie_player") is empty. I suppose that isn't really helping making it work, only i don't really understand why it's empty. The script isn't triggerd until someone actually clicks the link, so it its not like it doesn't exist because the page hasn't completely been loaded.


    Code:
    function toggleVisibility (open, close) {
    	
    	document.getElementById(open).style.display = "block";
    	document.getElementById(close).style.display = "none";
    		
    	if(open == 'video_content') {
    		var movie = document.getElementById("movie_player");
    		var m_source = 'mov/ronald_nootdorp.wmv';
    		var m_width = '293';
    		var m_height = '236';
    		var m_controller = '0';
    		var m_showcontrols = '0';
    		
    		/*if(self.movie) alert(movie) 
    			else alert("msg is not defined")*/
    		
    		movie.SetAttribute("src" , m_source);
    		movie.SetAttribute("width" , m_width);
    		movie.SetAttribute("height", m_height);
    		movie.SetAttribute("controller", m_controller);
    		movie.SetAttribute("showcontrols", m_showcontrols);
    	}
    		
    }
    The code that is supposed to be changed throught javascript

    Code:
    <embed id="movie_player" src="" width="" height="" controller="" showcontrols="" />
    Last edited by Tijmen; Aug 2, 2006 at 10:30.
    Travel Photos on Flickr - Twitter

    “Never give up. Never surrender”

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    JavaScript is case-sensitivte, therefore the error...

  3. #3
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    movie.SetAttribute should be movie.setAttribute

    or to spell it out:

    movie.SetAttribute...

    should be:

    movie.setAttribute...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •