converting inline js to external js

1,125 views
Skip to first unread message

sagar pandey

unread,
Oct 3, 2012, 4:58:32 PM10/3/12
to chromi...@chromium.org
hey guys the manifest version 1 gave up supporting inline javascript.... i need to convert them to be compatible with version 2 . please help me out 

Joe Marini

unread,
Oct 3, 2012, 5:07:51 PM10/3/12
to sagar pandey, Chromium Apps
Take any script content that is inside of <script> blocks, like this:

<script>
// some script code
</script>

and put it into an external file, then reference it like this:

<script src="myexternalcode.js"></script>

Also, take any inline event handlers, like:

<body onload="someFunction()">

Put it into an external JS file, then use addEventListener instead:

window.addEventListener("load", someFunction);

In other words, you can't have any script embedded in your HTML.



On Wed, Oct 3, 2012 at 1:58 PM, sagar pandey <sagari...@gmail.com> wrote:
hey guys the manifest version 1 gave up supporting inline javascript.... i need to convert them to be compatible with version 2 . please help me out 

--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-apps/-/ouuSZzhG5X0J.

To post to this group, send email to chromi...@chromium.org.
To unsubscribe from this group, send email to chromium-app...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/?hl=en.



--
Joe Marini
Developer Advocate / Chrome


Joshua Woodward

unread,
Oct 3, 2012, 5:08:03 PM10/3/12
to sagar pandey, chromi...@chromium.org
move all your code to an external js file, then include that in the head somewhere


is that what your looking for, or can you be more specific



On Wed, Oct 3, 2012 at 1:58 PM, sagar pandey <sagari...@gmail.com> wrote:
hey guys the manifest version 1 gave up supporting inline javascript.... i need to convert them to be compatible with version 2 . please help me out 

--
You received this message because you are subscribed to the Google Groups "Chromium Apps" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msg/chromium-apps/-/ouuSZzhG5X0J.

To post to this group, send email to chromi...@chromium.org.
To unsubscribe from this group, send email to chromium-app...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-apps/?hl=en.

Joshua Woodward

unread,
Oct 5, 2012, 12:26:45 PM10/5/12
to sagar pandey, chromi...@chromium.org
Sagar,

you sent me the code privately,and i made the changes, but wanted the response here in case others come across it.

First, you needed to redefine the default security policy to include the googleapis url
Second, "popup" now needs to be "default_popup" in browser_action
{
...
"browser_action": {
          ...
          "default_popup": "popup.html"
},
"content_security_policy": "script-src 'self' https://ajax.googleapis.com; object-src 'self'"
...
}

Third, all js in popup.html needed to be moved out to a external file, I created a main.js file for you and included it in the head of your html file
Fourth, the zrssfeed plugin you were using had no options set, I turned on ssl as an option, again for the content_security_policy to match, your feed was just http not https
Lastly, an easy one to miss, you were using jQuery 1.4.2, so I just changed it to 1.7.2 - you may want to check if everything is working for you like it should.


you can send the reward to pay...@woodwardmedia.net ;)
Reply all
Reply to author
Forward
0 new messages