linking to external CSS using insertCSS

316 views
Skip to first unread message

dmitry b

unread,
May 2, 2011, 4:57:42 PM5/2/11
to Chromium-extensions
Hi,

Is it possible to link to a css file using insertCSS rather than
inline the content of that file (seems the default current behavior).
The problem is that CSS is inlined, relative URLs inside the CSS will
be resolved relative to the HTML document. However, if CSS is linked
via <link rel="stylesheet" href="chrome-extension://asdfcasldcasdrwe/
mystyles.css> relative URLs inside of mystyles.css will be properly
resolved relatively to the .css file.


Thanks
Dmitry

Boris Smus

unread,
May 2, 2011, 10:37:13 PM5/2/11
to dmitry b, Chromium-extensions
Have you tried dynamically adding the <link> to the stylesheet? You could use programmatic injection for that: http://code.google.com/chrome/extensions/content_scripts.html#pi

You can get the URL to your stylesheet using http://code.google.com/chrome/extensions/extension.html#method-getURL

- Boris


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


dmitry b

unread,
May 3, 2011, 1:29:29 PM5/3/11
to Chromium-extensions
Yes, that's how I'm doing it now. But I'm interested in knowing how
to do this with chrome's insertCSS without a work-around.

On May 2, 7:37 pm, Boris Smus <s...@chromium.org> wrote:
> Have you tried dynamically adding the <link> to the stylesheet? You could
> use programmatic injection for that:http://code.google.com/chrome/extensions/content_scripts.html#pi
>
> You can get the URL to your stylesheet usinghttp://code.google.com/chrome/extensions/extension.html#method-getURL.
>
> - Boris
>
>
>
>
>
>
>
> On Mon, May 2, 2011 at 1:57 PM, dmitry b <dmitry.ma...@gmail.com> wrote:
> > Hi,
>
> > Is it possible to link to a css file using insertCSS rather than
> > inline the content of that file (seems the default current behavior).
> > The problem is that CSS is inlined, relative URLs inside the CSS will
> > be resolved relative to the HTML document.  However, if CSS is linked
> > via <link rel="stylesheet" href="chrome-extension://asdfcasldcasdrwe/
> > mystyles.css> relative URLs inside of mystyles.css will be properly
> > resolved relatively to the .css file.
>
> > Thanks
> > Dmitry
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Chromium-extensions" group.
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org.
Reply all
Reply to author
Forward
0 new messages