Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - javascript error - cisco web vpn

I have a very unique situation.

We use a Cisco Web VPN (don't know the exact name) here at work.

If I try to use the web pages I've developed, the javascript is broken.

I have tracked it down to this:

When using the Cisco Web VPN it will actually rewrite some of the HTML/JavaScript code. For instance, at the very beginning of the source it has stuck the following:

<script  id='CSCO_GHOST' src="/+CSCOL+/cte.js"></script>

This is directly after the <html> begin tag (and not inside the <head> tags).

Inside of that source, cte.js, there is an error. That error is causing jQuery to not function properly. cte.js is part of Cisco's product and is totally out of my control.

I know how to capture errors with the windows.onerror but that is not working for this situation. The error is occurring before my scripts are loaded into the page.

Any ideas on how to suppress this error or work around such a thing?

I had my <script> tags in the <head> and then moved them to the bottom of the <body> and in neither place does it make a difference.

UPDATE: After a bit more looking, it is something in jQuery. I commented out the <script> tag for jQuery and the error did not happen. Uncommented, the error came back.

like image 658
Lance Perry Avatar asked Aug 26 '09 15:08

Lance Perry


1 Answers

This is what I had to do to fix the problem. I created a JS file in my web project with the following code:

   if ( typeof SegmentHtml != "undefined" ) {
      SegmentHtmlParam.prototype['filter'] = function() {
         var name = null;
         var value = null;
         for (var i = 1; i < this._tokens.length; i++) {
            var token = this._tokens[i];
            if (token.type === ATTR_NAME) {
               name = csco_g_buffer.substring(token.first_index, token.last_index).toUpperCase();
            } else if (token.type === ATTR_VALUE) {
               value = csco_g_buffer.substring(token.first_index, token.last_index);
            };
         };
         var need_processing = false;
         if (ParserClsidName) {
            var tmp = ParserClsidName[this._clsid];
            if (tmp) {
               var proc = tmp[name];
               need_processing = typeof proc != 'undefined';
            };
         };
         /**
         * ERROR ON NEXT LINE: name is null
         */
         if (name!=null && name.toLowerCase() == "csco_proto") {
            this._parent['csco_proto'] = value;
         };
         if (need_processing) { this._parent[name] = value; };
      };    
   };

This is the FIRST javascript file I include in my HTML file.

<script type="text/javascript" src="js/jQueryCiscoKludge.js"></script>
like image 110
Lance Perry Avatar answered Nov 14 '22 21:11

Lance Perry