Tron
Tron

Reputation: 167

Syntax error that I can not find - may be affecting other things

I think I have a syntax error that may be affecting other things on my store. This error just started popping up:

(index):1544 Uncaught SyntaxError: Unexpected token <

Line 1544 of index, as I see it in the console under sources, has this:

1544 <script text="text/javascript">

I have never seen 'text=text' so I am wondering if that is what is causing the error. On top of that our product thumb nails wont respond, and there seems to be other negative effects as well, here are the other errors:

ERROR: product.functions.js:382 Uncaught ReferenceError: ProductThumbWidth is not defined

ERROR: product.functions.js:291 Uncaught ReferenceError: CurrentProdThumbImage is not defined(index):1609 Uncaught

ERROR: ReferenceError: ShowVariationThumb is not defined

I want to take care of the first syntax error message before I move on to the rest, and I am thinking that fixing it may fix other things and I think it is coming from here, ProductDetails.html. There may be a missing script tag, but I have never touched this file so I don't know why it would happen all of a sudden, and with the code that is commented out, it seems like it shouldn't affect it.

<script type="text/javascript">
var google_tag_params = {
ecomm_prodid: %%GLOBAL_ProductId%%, 
ecomm_pagetype: 'product',
ecomm_totalvalue: parseFloat('%%GLOBAL_ProductPrice%%'.replace("$","").replace(",",""))
};
</script>

<link rel="stylesheet" type="text/css" href="%%GLOBAL_CdnAppPath%%/javascript/jquery/themes/cupertino/ui.all.css?%%GLOBAL_JSCacheToken%%" />
<link rel="stylesheet" type="text/css" media="screen" href="%%GLOBAL_productAttributesCssPath%%?%%GLOBAL_JSCacheToken%%" />
<script type="text/javascript" src="%%GLOBAL_jQueryUIPath%%"></script>
<script type="text/javascript" src="%%GLOBAL_CdnAppPath%%/javascript/jquery/plugins/jquery.form.js?%%GLOBAL_JSCacheToken%%"></script>
<script type="text/javascript" src="%%GLOBAL_CdnAppPath%%/javascript/product.attributes.js?%%GLOBAL_JSCacheToken%%"></script>
<script type="text/javascript" src="%%GLOBAL_CdnAppPath%%/javascript/jquery/plugins/jCarousel/jCarousel.js?%%GLOBAL_JSCacheToken%%"></script>
%%SNIPPET_ProductImageZoomer%%

<script type="text/javascript">//<![CDATA[
var ThumbURLs = new Array();
var ProductImageDescriptions = new Array();
var CurrentProdThumbImage = %%GLOBAL_CurrentProdThumbImage%%;
var ShowVariationThumb =false;
var ProductThumbWidth = %%GLOBAL_ProductThumbWidth%%;
var ProductThumbHeight =  %%GLOBAL_ProductThumbHeight%%;
var ProductMaxZoomWidth = %%GLOBAL_ProductMaxZoomWidth%%;
var ProductMaxZoomHeight =  %%GLOBAL_ProductMaxZoomHeight%%;
var ProductTinyWidth = %%GLOBAL_ProductMaxTinyWidth%%;
var ProductTinyHeight =  %%GLOBAL_ProductMaxTinyHeight%%;

%%GLOBAL_ProdImageJavascript%%

//Don't enable Cloud Zoom (product image zoom) on touch device
//Mouseenter/Mouseover events are not ideal for touch devices
//for more info search for this code in /script/main.js

<script type="text/javascript">
  var _learnq = _learnq || [];

  var item = {
    Name: "%%GLOBAL_ProductName%%", 
    ProductID: %%GLOBAL_ProductId%%,
    ImageURL: "%%GLOBAL_CurrentProdThumbImage%%",
    URL: window.location.origin + window.location.pathname,
    Brand: "%%GLOBAL_BrandName%%",
    Price: "%%GLOBAL_ProductPrice%%",
    CompareAtPrice: "%%GLOBAL_RetailPrice%%"
  };

  _learnq.push(['track', 'Viewed Product', item]);
  _learnq.push(['trackViewedItem', {
    Title: item.Name,
    ItemId: item.ProductID,
    ImageUrl: item.ImageURL,
    Url: item.URL,
    Metadata: {
      Brand: item.Brand,
      Price: item.Price,
      CompareAtPrice: item.CompareAtPrice
    }
  }]);
</script>

<script type="text/javascript"> 
if (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0)){
    var ShowImageZoomer = false;
} else {
    var ShowImageZoomer = %%GLOBAL_ShowImageZoomer%%;
}

var productId = %%GLOBAL_ProductId%%;
//]]></script>

Here are screens of the console errors, and sources tab: enter image description here enter image description here

Any help is much appreciated!

Upvotes: 2

Views: 236

Answers (2)

aghidini
aghidini

Reputation: 3010

Without seeing you whole page I'm only guessing, but from the error it looks like you are already inside a <script> tag on line 1544. Double check your sources, maybe you are not closing a previous <script> tag.

After that you should use type="text/javascript" albeit it's the default and not necessary, you can just use <script>...</script>.

Upvotes: 3

Munawir
Munawir

Reputation: 3356

Change

<script text="text/javascript">

to

<script type="text/javascript">

it's type= not text=

Upvotes: 0

Related Questions