Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Chrome stop certain javascript code from running because of its extensions?

I have a small code in my page with

 <script type="text/javascript">
 function doPost() {
 document.forms["form"].submit();
}  
  function Func1Delay()
{
setTimeout("doPost()", 0);
}

....

   <body onload="Func1Delay()">

I have this error in the console saying

Uncaught TypeError: Cannot call method 'create' of undefined

and on the right, it's due to the chrome extension MeasureIt. When I disable it, my script works. Is there a workaround for this problem?

like image 231
Matt Avatar asked May 31 '12 04:05

Matt


1 Answers

The short answer is YES. But the complete answer is NO, it's not Chrome, but some extension who interfere with your code. For example:

1) A content script can add a listener and use stopPropagation. In this case your code won't receive that event. I can image a more specific scenario where the content script fails and therefore prevents other listeners to execute.

2) A content script can mess with your page's elements. It can remove some, and add its owm. What would happen if the extension add a SCRIPT element with a var or function named exactly the same that one of yours?

We cannot be sure about how "well" the extension's code is written.

By the way, there is a lot of Chrome's extensions that interfere with pages. Some months ago Skype extension for Chrome was found guilty of interfere and destabilize web pages and video playback in that browser.

like image 158
Alejandro Silvestri Avatar answered Oct 21 '22 05:10

Alejandro Silvestri