SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot keith5885's Avatar
    Join Date
    Jun 2006
    Location
    at my computer
    Posts
    143
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Script Error - Not sure why - Image Slideshow

    Hey JavaScript forum,

    I used some javascipt issues. I keep geting a Script error that says

    Line:207
    Char:7
    Code:0
    Error:'document.images.SlideShow.style' is null or not an object

    Line 207 is:
    Code:
       document.images.SlideShow.style.filter="blendTrans(duration=2)"
    Now the entire code so you can hopefully see why I am getting this error is here. It wasnt causing a problem before without the Flash Detection code so I don't know if that has anything to do with it.

    Basically here is the page... http://schroedermachinetechnologies.com/
    and it should play the video if you have the right version plugin and the slideshow if you don't.

    Code:
    <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!--
    // -----------------------------------------------------------------------------
    // Globals
    // Major version of Flash required
    var requiredMajorVersion = 8;
    // Minor version of Flash required
    var requiredMinorVersion = 0;
    // Revision of Flash required
    var requiredRevision = 0;
    // the version of javascript supported
    var jsVersion = 1.0;
    // -----------------------------------------------------------------------------
    // -->
    </SCRIPT>
    <SCRIPT LANGUAGE="VBScript" TYPE="text/vbscript">
    <!-- // Visual basic helper required to detect Flash Player ActiveX control version information
    Function VBGetSwfVer(i)
      on error resume next
      Dim swControl, swVersion
      swVersion = 0
      
      set swControl = CreateObject("ShockwaveFlash.ShockwaveFlash." + CStr(i))
      if (IsObject(swControl)) then
        swVersion = swControl.GetVariable("$version")
      end if
      VBGetSwfVer = swVersion
    End Function
    // -->
    </SCRIPT>
    <SCRIPT LANGUAGE="JavaScript1.1" TYPE="text/javascript">
    <!-- // Detect Client Browser type
    var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
    var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
    var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
    jsVersion = 1.1;
    // JavaScript helper required to detect Flash Player PlugIn version information
    function JSGetSwfVer(i){
    	// NS/Opera version >= 3 check for Flash plugin in plugin array
    	if (navigator.plugins != null && navigator.plugins.length > 0) {
    		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
    			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
          		var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
    			descArray = flashDescription.split(" ");
    			tempArrayMajor = descArray[2].split(".");
    			versionMajor = tempArrayMajor[0];
    			versionMinor = tempArrayMajor[1];
    			if ( descArray[3] != "" ) {
    				tempArrayMinor = descArray[3].split("r");
    			} else {
    				tempArrayMinor = descArray[4].split("r");
    			}
          		versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
                flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
          	} else {
    			flashVer = -1;
    		}
    	}
    	// MSN/WebTV 2.6 supports Flash 4
    	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
    	// WebTV 2.5 supports Flash 3
    	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
    	// older WebTV supports Flash 2
    	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
    	// Can't detect in all other cases
    	else {
    		
    		flashVer = -1;
    	}
    	return flashVer;
    } 
    // If called with no parameters this function returns a floating point value 
    // which should be the version of the Flash Player or 0.0 
    // ex: Flash Player 7r14 returns 7.14
    // If called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
    function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) 
    {
     	reqVer = parseFloat(reqMajorVer + "." + reqRevision);
       	// loop backwards through the versions until we find the newest version	
    	for (i=25;i>0;i--) {	
    		if (isIE && isWin && !isOpera) {
    			versionStr = VBGetSwfVer(i);
    		} else {
    			versionStr = JSGetSwfVer(i);		
    		}
    		if (versionStr == -1 ) { 
    			return false;
    		} else if (versionStr != 0) {
    			if(isIE && isWin && !isOpera) {
    				tempArray         = versionStr.split(" ");
    				tempString        = tempArray[1];
    				versionArray      = tempString .split(",");				
    			} else {
    				versionArray      = versionStr.split(".");
    			}
    			versionMajor      = versionArray[0];
    			versionMinor      = versionArray[1];
    			versionRevision   = versionArray[2];
    			
    			versionString     = versionMajor + "." + versionRevision;   // 7.0r24 == 7.24
    			versionNum        = parseFloat(versionString);
            	// is the major.revision >= requested major.revision AND the minor version >= requested minor
    			if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) {
    				return true;
    			} else {
    				return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false );	
    			}
    		}
    	}	
    	return (reqVer ? false : 0.0);
    }
    // -->
    </SCRIPT>
    <SCRIPT>
    <!--
    // =======================================
    
    // set the following variables
    
    // =======================================
    
    
    
    // Set slideShowSpeed (milliseconds)
    
    var slideShowSpeed = 2500
    
    
    
    // Duration of crossfade (seconds)
    
    var crossFadeDuration = 3
    
    
    
    // Specify the image files
    
    var Pic = new Array() // don't touch this
    
    // to add more images, just continue
    
    // the pattern, adding to the array below
    
    
    
    Pic[0] = 'Images/Home/Main1.jpg'
    
    Pic[1] = 'Images/Home/Main2.jpg'
    
    Pic[2] = 'Images/Home/Main3.jpg'
    
    
    
    
    // =======================================
    
    // do not edit anything below this line
    
    // =======================================
    
    
    
    var t
    
    var j = 0
    
    var p = Pic.length
    
    
    
    var preLoad = new Array()
    
    for (i = 0; i < p; i++){
    
       preLoad[i] = new Image()
    
       preLoad[i].src = Pic[i]
    
    }
    
    
    
    function runSlideShow(){
    
       if (document.all){
    
          document.images.SlideShow.style.filter="blendTrans(duration=2)"
    
          document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
    
          document.images.SlideShow.filters.blendTrans.Apply()      
    
       }
    
       document.images.SlideShow.src = preLoad[j].src
    
       if (document.all){
    
          document.images.SlideShow.filters.blendTrans.Play()
    
       }
    
       j = j + 1
    
       if (j > (p-1)) j=0
    
       t = setTimeout('runSlideShow()', slideShowSpeed)
    
    }
    
    function MM_preloadImages() { //v3.0
      var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
        var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
        if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
    }
    
    function MM_swapImgRestore() { //v3.0
      var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
    }
    
    function MM_findObj(n, d) { //v4.01
      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
      if(!x && d.getElementById) x=d.getElementById(n); return x;
    }
    
    function MM_swapImage() { //v3.0
      var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
       if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
    }
    //-->
    </SCRIPT>
    <BODY TOPMARGIN="0" LEFTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0" BGCOLOR="#dddddd" onLoad="runSlideShow();MM_preloadImages('Images/Nav/MainMenu/MenuRollOver_06.gif','Images/Nav/MainMenu/MenuRollOver_07.gif','Images/Nav/MainMenu/MenuRollOver_08.gif','Images/Nav/MainMenu/MenuRollOver_09.gif','Images/Nav/MainMenu/MenuRollOver_11.gif','Images/Nav/MainMenu/MenuRollOver_12.gif','Images/Nav/MainMenu/MenuRollOver_02.gif','Images/Nav/MainMenu/MenuRollOver_03.gif','Images/Nav/MainMenu/MenuRollOver_04.gif')">
    <!-- Start of StatCounter Code -->
    <SCRIPT TYPE="text/javascript" LANGUAGE="javascript">
    var sc_project=1637055; 
    var sc_invisible=1; 
    var sc_partition=15; 
    var sc_security="1f1e3929"; 
    </SCRIPT>
    
    <SCRIPT TYPE="text/javascript" LANGUAGE="javascript" SRC="http://www.statcounter.com/counter/counter.js"></SCRIPT><NOSCRIPT>
    <A HREF="http://www.statcounter.com/" TARGET="_blank">	<IMG  src="http://c16.statcounter.com/counter.php?sc_project=1637055&amp;java=0&amp;security=1f1e3929&amp;invisible=1" ALT="web stats script" BORDER="0"></A> </NOSCRIPT>
     <!-- End of StatCounter Code -->
    
    <CENTER>   
    <TABLE WIDTH="760" HEIGHT="101" BORDER="0" CELLPADDING="0" CELLSPACING="0">
    	<TR>
    		<TD COLSPAN="5" ROWSPAN="2">
    			<A HREF="index.html"><IMG SRC="Images/Nav/MainMenu/MenuLarge_01.gif" ALT="Home" WIDTH="449" HEIGHT="73" BORDER="0"></A></TD>
    		<TD>
    			<A HREF="index.html"><IMG SRC="Images/Nav/MainMenu/MenuLarge_02.gif" ALT="Home" WIDTH="84" HEIGHT="35" BORDER="0" ID="Image7" onMouseOver="MM_swapImage('Image7','','Images/Nav/MainMenu/MenuRollOver_02.gif',1)" onMouseOut="MM_swapImgRestore()"></A></TD>
    		<TD COLSPAN="3">
    			<A HREF="AboutUs.html"><IMG SRC="Images/Nav/MainMenu/MenuLarge_03.gif" ALT="About Us" WIDTH="127" HEIGHT="35" BORDER="0" ID="Image8" onMouseOver="MM_swapImage('Image8','','Images/Nav/MainMenu/MenuRollOver_03.gif',1)" onMouseOut="MM_swapImgRestore()"></A></TD>
    	  <TD>
    	    <A HREF="SiteMap.html"><IMG SRC="Images/Nav/MainMenu/MenuLarge_04.gif" ALT="Site Map" WIDTH="100" HEIGHT="35" BORDER="0" ID="Image9" onMouseOver="MM_swapImage('Image9','','Images/Nav/MainMenu/MenuRollOver_04.gif',1)" onMouseOut="MM_swapImgRestore()"></A></TD>
    	</TR>
    	<TR>
    		<TD COLSPAN="5">
    			<IMG SRC="Images/Nav/MainMenu/MenuLarge_05.gif" WIDTH="311" HEIGHT="38" ALT=""></TD>
    	</TR>
    	<TR>
    		<TD>
    			<A HREF="Products.html"><IMG SRC="Images/Nav/MainMenu/MenuLarge_06.gif" ALT="Products" WIDTH="84" HEIGHT="27" BORDER="0" ID="Image1" onMouseOver="MM_swapImage('Image1','','Images/Nav/MainMenu/MenuRollOver_06.gif',1)" onMouseOut="MM_swapImgRestore()"></A></TD>
    		<TD>
    			<A HREF="Automation.html"><IMG SRC="Images/Nav/MainMenu/MenuLarge_07.gif" ALT="Automation" WIDTH="98" HEIGHT="27" BORDER="0" ID="Image2" onMouseOver="MM_swapImage('Image2','','Images/Nav/MainMenu/MenuRollOver_07.gif',1)" onMouseOut="MM_swapImgRestore()"></A></TD>
    		<TD>
    			<A HREF="Customization.html"><IMG SRC="Images/Nav/MainMenu/MenuLarge_08.gif" ALT="Customization" WIDTH="113" HEIGHT="27" BORDER="0" ID="Image3" onMouseOver="MM_swapImage('Image3','','Images/Nav/MainMenu/MenuRollOver_08.gif',1)" onMouseOut="MM_swapImgRestore()"></A></TD>
    		<TD>
    			<A HREF="FullMetalShop.html"><IMG SRC="Images/Nav/MainMenu/MenuLarge_09.gif" ALT="Full Metal Shop" WIDTH="125" HEIGHT="27" BORDER="0" ID="Image4" onMouseOver="MM_swapImage('Image4','','Images/Nav/MainMenu/MenuRollOver_09.gif',1)" onMouseOut="MM_swapImgRestore()"></A></TD>
    		<TD COLSPAN="3">
    			<IMG SRC="Images/Nav/MainMenu/MenuLarge_10.gif" WIDTH="175" HEIGHT="27" ALT=""></TD>
    		<TD>
    			<A HREF="MembersLogin.php"><IMG SRC="Images/Nav/MainMenu/MenuLarge_11.gif" ALT="Login" WIDTH="58" HEIGHT="27" BORDER="0" ID="Image5" onMouseOver="MM_swapImage('Image5','','Images/Nav/MainMenu/MenuRollOver_11.gif',1)" onMouseOut="MM_swapImgRestore()"></A></TD>
    		<TD COLSPAN="2">
    			<A HREF="ContactUs.html"><IMG SRC="Images/Nav/MainMenu/MenuLarge_12.gif" ALT="Contact Us" WIDTH="107" HEIGHT="27" BORDER="0" ID="Image6" onMouseOver="MM_swapImage('Image6','','Images/Nav/MainMenu/MenuRollOver_12.gif',1)" onMouseOut="MM_swapImgRestore()"></A></TD>
    	</TR>
    	<TD ALIGN="LEFT" VALIGN="top" BGCOLOR="#FFFFFF" CLASS="texthome" STYLE="padding:0px 10px 0px 0px">
    	<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
    <!-- 
    var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
    if(hasRightVersion) {  // if we've detected an acceptable version
        var oeTags = '<EMBED SRC="homevideo.swf" QUALITY="high" BGCOLOR="#ffffff" WIDTH="265" HEIGHT="176" NAME="homevideo" ALIGN="middle" allowScriptAccess="sameDomain" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" />';
        document.write(oeTags);   // embed the flash movie
      } else {  // flash is too old or we can't detect the plugin
        var alternateContent = '<IMG SRC="Images/Home/Main1.jpg" name="SlideShow" WIDTH="265" HEIGHT="176" ALIGN="LEFT">';
        document.write(alternateContent);  // insert non-flash content
      }
    // -->
    </SCRIPT>
    <NOSCRIPT>
    	<IMG SRC="Images/Home/Main1.jpg" name="SlideShow" WIDTH="265" HEIGHT="176" ALIGN="LEFT">;
    </NOSCRIPT>
    I know thats a lot of code... hopefully any guidance will help
    Thanks Sitepoint!

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,440
    Mentioned
    160 Post(s)
    Tagged
    1 Thread(s)

    SlideShow

    Maybe something like
    HTML Code:
    var ss_img = document.getElementById('SlideShow');
    ss_img.style.filter="blendTrans(duration=2)"
    would work. The only problems I can see is that there might possibly be more than 1 element with the same id, or runSlideShow may have to run after the script writes the img tag for the ss script to find the tag.


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
  •