Question

I am trying to have a javascript set a cookie that tells Google Translate which language to set the page.

I have tried this based on my browser's cookie when selecting a language.

<script>

$(document).ready(function(){
  setcookie(“googtrans”, “/en/fr”, time()+3600, “/”, “www.example.com”);
  setcookie(“googtrans”, “/en/fr”, time()+3600, “/”, “.example.com”);
});

</script>

I am not very good with javascript and I get an unexpected token ILLEGAL, not sure what this means:

<script>(function() {with (this[2]) {with (this[1]) {with (this[0]) {return function(event) {ccm_exitVersionList()
};}}}})</script>

Is my script wrong? Any help appreciated.

Was it helpful?

Solution

JavaScript strings must be quoted with " (QUOTATION MARK) or ' (APOSTROPHE) not (LEFT DOUBLE QUOTATION MARK) and (RIGHT DOUBLE QUOTATION MARK).

This error is typically caused by writing code using a word processor that automatically inserts typographic quotes.

Use a text editor designed for programmers (such as Sublime, Vim, Emacs, Komodo, TextMate, Notepad++, BBEdit, or Eclipse) instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top