chrome.tabs.onCreated.addListener(function(Tab tab) {log('success');});Uncaught SyntaxError: Unexpected identifier

1,473 views
Skip to first unread message

Shashi Bhushan

unread,
Feb 1, 2010, 12:14:18 PM2/1/10
to Chromium-extensions

Hi,

This line chrome.tabs.onCreated.addListener(function(Tab tab) {log
('success');});

give following error Uncaught SyntaxError: Unexpected identifier

How to resolve this error? Thanks in advance.

Thanks,

Shashi

<html>


<head>


<style>


.my_table {


margin:2px;


font-family:Arial;


font-size:11px;


border: solid 1px #aaaaaa;


}

.my_table tr.odd {


background-color:#fff5cc;


}

.my_table tr.even {


background-color:#ffffff;


}

.my_table td {


padding: 3px;


vertical-align:top;


}

.my_table td.rborder {


border-right: solid 1px #aaaaaa;


}

.my_table td.bborder {


border-bottom: solid 1px #aaaaaa;


}

.my_table td.tborder {


border-top: solid 1px #aaaaaa;


}

.my_table td.ralign {


text-align: right;


}

.my_table td.calign {


text-align: center;


}

.my_table tr.heading td {


padding: 5px;


font-weight: bold;


text-align: center;


background-color: #aff2fb;


}

.my_table td.odd {


background-color: #aff2fb;


}

.my_table td.even {


background-color: #ffffff;


}

.style1 {


font-size: 12px;


font-weight: bold;


color: #000000;


line-height: 1.5;


}


</style>


<script>


var logging = true;


var tabCount = 'TABCOUNT';


var tabCountValue = 0;


function populate() {

tabValueCount = getValue(tabCount);


log('leaving populate()');


}

function getValue(key) {


console.log(key);


return chrome.extension.getBackgroundPage().getItem(key);


}


function log(txt) {


if(logging) {


chrome.extension.getBackgroundPage().log(txt);


}


}

</script>


<script type="text/javascript">


function init()


{


chrome.tabs.onCreated.addListener(function(Tab tab) {log
('success');});

Uncaught SyntaxError: Unexpected identifier


populate();


}


</script>


</head>


<body onload='init()'>

Uncaught ReferenceError: init is not defined


<form name='form1'>


<table class="my_table" cellpadding="0" cellspacing="0" width=200px>


<tr>


<td class="style1" colspan="2" align="center">Total Counter</td>


</tr>


<tr class="odd">


<td class="rborder" >Tab Count</td>


<td class="ralign"><div id='tabCount'></div></td>


</tr>

</table>


</form>


</body>


</html>

Brian Kennish

unread,
Feb 1, 2010, 12:44:02 PM2/1/10
to Shashi Bhushan, Chromium-extensions
On Mon, Feb 1, 2010 at 9:14 AM, Shashi Bhushan <shas...@gmail.com> wrote:
> This line chrome.tabs.onCreated.addListener(function(Tab tab) {log
> ('success');});
>
>  give following error Uncaught SyntaxError: Unexpected identifier

The type "Tab" shouldn't be there. Also, the function "log" won't be
defined unless you've done so yourself -- you probably mean
"console.log". So:

chrome.tabs.onCreated.addListener(function(tab) {
console.log('success');
});

Reply all
Reply to author
Forward
0 new messages