Solved

Javascript Unterminated string literal error

Posted on 2008-06-25
16
2,089 Views
Last Modified: 2013-11-19
Getting an error with firebug: "unterminated string literal".  I know it's something simple...but I'm not seeing it:
var slideshow = '<script type="text/javascript">AC_FL_RunContent( \'codebase\',\'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\',\'width\',\'350\',\'height\',\'234\',\'title\',\'Fire Sprinkler Images\',\'src\',\'preview\',\'quality\',\'high\',\'pluginspage\',\'http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\',\'movie\',\'preview\' ); </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="350" height="234" title="Fire Sprinkler Images"><param name="movie" value="preview.swf" /><param name="quality" value="high" /><embed src="preview.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="350" height="234"></embed></object></noscript>';

Open in new window

0
Comment
Question by:rowejd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 7
16 Comments
 
LVL 41

Expert Comment

by:HonorGod
ID: 21868240
wouldn't it be easier to consistently use double quotes?
var slideshow = '<script type="text/javascript">AC_FL_RunContent( "codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0","width","350","height","234","title","Fire Sprinkler Images","src","preview","quality","high","pluginspage","http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash","movie","preview" );</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="350" height="234" title="Fire Sprinkler Images"><param name="movie" value="preview.swf" /><param name="quality" value="high" /><embed src="preview.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="350" height="234"></embed></object></noscript>';

Open in new window

0
 
LVL 12

Author Comment

by:rowejd
ID: 21868266
Yes - that's just the auto code generated by Dreamweaver.  Changed it, but still gives me the error.

here's the code in-context:
	function loadflash() {
		var slideshow = '<script type="text/javascript">AC_FL_RunContent( "codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0","width","350","height","234","title","Fire Sprinkler Images","src","preview","quality","high","pluginspage","http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash","movie","preview" );</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="350" height="234" title="Fire Sprinkler Images"><param name="movie" value="preview.swf" /><param name="quality" value="high" /><embed src="preview.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="350" height="234"></embed></object></noscript>';
	    document.getElementById("homeflash").innerHTML = slideshow;		
	}

Open in new window

0
 
LVL 12

Author Comment

by:rowejd
ID: 21868271
Sorry meant to do the whole thing...
<script type="text/javascript">
	window.onload = function () { loadflash(); }
	
	function loadflash() {
		var slideshow = '<script type="text/javascript">AC_FL_RunContent( "codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0","width","350","height","234","title","Fire Sprinkler Images","src","preview","quality","high","pluginspage","http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash","movie","preview" );</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="350" height="234" title="Fire Sprinkler Images"><param name="movie" value="preview.swf" /><param name="quality" value="high" /><embed src="preview.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="350" height="234"></embed></object></noscript>';
	    document.getElementById("homeflash").innerHTML = slideshow;		
	}
</script>

Open in new window

0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 12

Author Comment

by:rowejd
ID: 21868293
Nice profile, by the way.  I'm a seminary student coding my way through school.  My majors were bible & biblical languages -- going for my MDiv now.
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21868382
Cool.  Good luck on that.

Option #1 - do you get the "Element not found" message?
<script type="text/javascript">
  window.onload = function () { loadflash(); }
        
  function loadflash() {
    var slideshow = '<script type="text/javascript">AC_FL_RunContent( "codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0","width","350","height","234","title","Fire Sprinkler Images","src","preview","quality","high","pluginspage","http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash","movie","preview" );</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="350" height="234" title="Fire Sprinkler Images"><param name="movie" value="preview.swf" /><param name="quality" value="high" /><embed src="preview.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="350" height="234"></embed></object></noscript>';
    var home = document.getElementById( "homeflash" );
    if ( home ) {
      home.innerHTML = slideshow;         
    } else {
      alert( 'Element not found.  id="homeflas"' );
    }
  }
</script>

Open in new window

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21868407
Option #2
<script type="text/javascript">
  window.onload = function () { 
    AC_FL_RunContent( "codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0","width","350","height","234","title","Fire Sprinkler Images","src","preview","quality","high","pluginspage","http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash","movie","preview" );
  }
</script>
 
<noscript>
  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="350" height="234" title="Fire Sprinkler Images">
    <param name="movie" value="preview.swf" />
    <param name="quality" value="high" />
      <embed src="preview.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="350" height="234"></embed>
  </object>
</noscript>

Open in new window

0
 
LVL 12

Author Comment

by:rowejd
ID: 21868514
Still no dice.  I see part of the javascript show at the top of my page.

Here's where I'm trying to use it.  I'm using the onload function simply because I want the rest of the page to load first and then the flash.

http://dime159.dizinc.com/~firespri/
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21868552
Interesting, in the top of my FireFox 3, window (i.e., between the tabs, and the main page), I see:

'; var home = document.getElementById( "homeflash" ); if ( home ) { home.innerHTML = slideshow; } else { alert( 'Element not found. id="homeflas"' ); } }

So, presumably you are talking about option #1.  Right?
0
 
LVL 12

Author Comment

by:rowejd
ID: 21868560
correct.  I used option 1...but tried 2 as well and it gives me other errors.  I just can't figure out why option 1 wouldn't work though?
0
 
LVL 41

Accepted Solution

by:
HonorGod earned 500 total points
ID: 21868596
Change line 12 to be:
var slideshow = '<script type="text\/javascript">AC_FL_RunContent( "codebase","http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=9,0,28,0","width","350","height","234","title","Fire Sprinkler Images","src","preview","quality","high","pluginspage","http:\/\/www.adobe.com\/shockwave\/download\/download.cgi?P1_Prod_Version=ShockwaveFlash","movie","preview" );<\/script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=9,0,28,0" width="350" height="234" title="Fire Sprinkler Images"><param name="movie" value="preview.swf" \/><param name="quality" value="high" \/><embed src="preview.swf" quality="high" pluginspage="http:\/\/www.adobe.com\/shockwave\/download\/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application\/x-shockwave-flash" width="350" height="234"><\/embed><\/object><\/noscript>';

Open in new window

0
 
LVL 12

Author Comment

by:rowejd
ID: 21868647
No errors in the javascript now...but no flash content in the div?
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21868670
Unfortunately, I don't know anything about Flash, or the function:

AC_FL_RunContent()
0
 
LVL 12

Author Comment

by:rowejd
ID: 21868689
Well...if you care to check it out -- here's what it looks like working:

http://clearlyconsulting.org   (temporary testing)

This is without any javascript onload functionality...same exact code, so it shouldn't have anything to do with that right?  Let me know what you think?
0
 
LVL 12

Author Comment

by:rowejd
ID: 21868772
Well, you were right about the AC_FL_RunContent() deal -- that's what was messing things up.

I took out the noscript tags and the AC function and just used the object tags and it worked fine.  Thanks for the help!
0
 
LVL 12

Author Closing Comment

by:rowejd
ID: 31470673
Thanks so much --- totally forgot to consider the URL slashes needing to be escaped!
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 21868898
Ah, that is excellent news!  I'm glad to have been of some help.

Thanks for the grade and the points.

Good luck, and have a great day.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question