ecross102301
asked on
I have javascript syntax errors while trying to use a form
I am getting syntax errors in this script and I can't seem to find the errors. Can someone please help me?
<script type="text/javascript">
function utmx_section(){}function utmx(){}
(function(){var k='0790041258',d=document,l=d.location,c=d.cookie;function f(n){
if(c){var i=c.index0f(n+'=');if(i>-l){var j=c.index0f(';',i);return c.substring(i+n.length+1,j<0?c.length:j)}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;
d.write('<sc'+'ript' src="'+'http'+(l.protocol=='httpd:'?'s://ssl':'://www')+'.google-analytics.com'+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+'" type="text/javascript" charset="utf-8"><'/sc'+'ript>')})();
</script>
<script>
Why in the world are you writing, or using code like this?
Line 8 is unneeded/wrong
And 5 should probably be:
Line 8 is unneeded/wrong
And 5 should probably be:
d.write( '<sc' + 'ript' src= "'+'http'+(l.protocol=='httpd:'?'s://ssl':'://www')+'.google-analytics.com'+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+' type="text/javascript" charset="utf-8"><'/sc'+'ript>' )
webwyzsystems, you and I did the same thing... :-)
ASKER
I have implemented your suggestions but now how more errors. HonorGod what is line 8 that I need to removest
Your line 8 above is the last in your "snippet", i.e.,
unless, of course, you have script code after that....
unless, of course, you have script code after that....
<script>
ASKER
I have implemented the suggestions you requested and now have more syntax errors...please advise. As this made things worse.
Well, webwyzsystems and I started down the same route, and expanded/formatted it in a similar fashion.
The big problem appears to the the content of the d.write() call.
It starts like this:
'<sc'+'ript' src="'
which is a problem, because the first string (i.e., '<sc' is then concatentated with the next string (i.e., 'ript'). So far, so good. This is equivalent to:
'<script'
Then, we start running into problems. because the src=" should really be in a string. So, let's see if we can change the start to:
'<sc'+'ript src="'
This is then followed by + and another string, so this may be alright.
Continuing in this way, it appears that this may be the proper d.write() line:
d.write( '<sc'+'ript src="'+'http'+(l.protocol= ='httpd:'? 's://ssl': '://www')+ '.google-a nalytics.c om'+'/site opt.js?v=1 &utmxkey=' +k+'&utmx= '+(x?x:'') +'&utmxx=' +(xx?xx:'' )+'&utmxti me='+new Date().valueOf()+(h?'&utmx hash='+esc ape(h.subs tr(1)):'') +'" type="text/javascript" charset="utf-8"></sc'+'rip t>' )
The big problem appears to the the content of the d.write() call.
It starts like this:
'<sc'+'ript' src="'
which is a problem, because the first string (i.e., '<sc' is then concatentated with the next string (i.e., 'ript'). So far, so good. This is equivalent to:
'<script'
Then, we start running into problems. because the src=" should really be in a string. So, let's see if we can change the start to:
'<sc'+'ript src="'
This is then followed by + and another string, so this may be alright.
Continuing in this way, it appears that this may be the proper d.write() line:
d.write( '<sc'+'ript src="'+'http'+(l.protocol=
<script type="text/javascript">
function utmx_section(){
}
function utmx(){
}
( function() {
var k = '0790041258', d = document, l = d.location, c = d.cookie;
function f( n ) {
if( c ) {
var i = c.index0f( n + '=' );
if ( i >- l ) {
var j = c.index0f( ';', i );
return c.substring( i + n.length + 1, j < 0 ? c.length : j )
}
}
}
var x = f ('__utmx'), xx = f( '__utmxx' ), h = l.hash;
d.write( '<sc'+'ript' src="'+'http'+(l.protocol=='httpd:'?'s://ssl':'://www')+'.google-analytics.com'+'/siteopt.js?v=1&utmxkey='+k+'&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+'" type="text/javascript" charset="utf-8"><'/sc'+'ript>' )
}
)();
</script>
ASKER
Now we are back to the original error
Syntax error: Missing ) after argument list
See: src="'+'http'+(l.protocol= ='httpd:'? 's://ssl': '://www')+ '.google-a nalytics.c om'+'/site opt.js?v=1 &utmxkey=' +k+'&utmx= '+(x?x:'') +'&utmxx=' +(xx?xx:'' )+'&utmxti me='+new Date().valueOf()+(h?'&utmx hash='+esc ape(h.subs tr(1)):'') +'" type="text/javascript" charset="utf-8"><'/sc'+'ri pt>' )
}
)();
</script>
Syntax error: Missing ) after argument list
See: src="'+'http'+(l.protocol=
}
)();
</script>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ah good. Thanks for the code and points.
Good luck & have a great day
Good luck & have a great day
I don't have a lot of time unfortunately - hopefully this one is accurate:
Open in new window