3

Ok,

So I have been using firebug and also some extensions I wrote to create shortcuts on website I use often. There's on thing that I don't understand why it doesn't work or why it's not possible:

Example code:

<input type="button" onclick="addNewRow()" id="addRow"/>
//This will add a new row to the current table.
//The function is defined by the website (not my function)

When using firebug:

jQuery("#addRow").click();
//This will simulate the button click, and will automatically add the new row.

When using google chrome extension:

jQuery("#addRow").click();
//It doesn't add the new row.

Why can't the extension execute the function once the button click occurs, and why firebug has no issues in running it?

Is this normal? Is this a security feature? or am I doing something wrong?

I know that I can't access existing functions in a website for security reasons, but why won't the button simulation trigger it for me?

4
  • My issue is that i can get the code to trigger the function using firebug, but I can't get it to work when using it as an extension. The jQuery selection works, but the function is never triggered. I believe the same issues happens if I use the extension in Firefox (using userscripts/greasymonkey) So I can accomplish what I want in firebug, but I would rather have it in a extension so I don't have to copy and paste code all the time. Commented Mar 8, 2012 at 16:03
  • I tried running my extension in firefox using the jquery trigger option, but it did not work either. Commented Mar 9, 2012 at 17:19
  • ahhhhhhhhhhhhh i am having this same issue, and it is making me go crazy. O_O Commented Apr 30, 2012 at 3:23
  • After much reading, it seems that google extensions don't give you access to a website's existing function. That doesn't explain why it work in the debug console though. Commented Apr 3, 2013 at 18:43

3 Answers 3

2

Try:

jQuery("#addRow").trigger("click");
Sign up to request clarification or add additional context in comments.

2 Comments

Unfortunately, trigger did not work in the extension either. It worked is I just open the chrome console and add it there (just as firebug)
Are there any settings that I need to enable in the manafesto file?
1

What version of Chrome are you using ? There is a new Chrome Extensions security feature that blocks inline javascript. You can read more here : http://browserfame.com/512/chrome-extension-content-security-policy

Comments

0

On chrome, I would rather use WebKit's developer console rather than firebug extention.

1 Comment

Yes, I noticed that firebug does not work as well on chrome as it does on firefox. I was actually running firebug on firefox.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.