OpenWindow with new CSS

S

Syl

I'm using a CMS that applies the web site theme to every page within
the web site,.
I have a OpenWindow function that opens a popup window for some
hyperlinks.

Can I use javascript to access a different CSS file in the popup
window ?
The CSS file with then use display:none to hide the banner, side
navigation, etc.

Thanks
 
R

RobG

I'm using a CMS that applies the web site theme to every page within
the web site,.
I have a OpenWindow function that opens a popup window for some
hyperlinks.

Can I use javascript to access a different CSS file in the popup
window ?
Yes.

The CSS file with then use display:none to hide the banner, side
navigation, etc.

Thanks

No problem.
 
S

Syl

Can I use javascript to access a different CSS file in the popup
window ?
The CSS file with then use display:none to hide the banner, side
navigation, etc.

Does anyone have any useful advice on how to access a different css in
a popup window ?

Thanks
 
D

Dr J R Stockton

In comp.lang.javascript message <90f2fb79-b6a1-4da0-ad14-c6067173f86b@w3
0g2000yqw.googlegroups.com>, Sat, 28 Aug 2010 06:17:05, Syl
Does anyone have any useful advice on how to access a different css in
a popup window ?

Search the Web for createStyleSheet and see whether it helps.
 
R

RobG

Does anyone have any useful advice on how to access a different css in
a popup window ?

You can remove all current style sheets:

var sheets = document.getElementsByTagName('link');
var i = sheets.length;
while (i--) {
sheets.parentNode.removeChild(sheets);
}

You can use similar code to remove all style elements.

You can add a new style sheet that can be used for new rules and to
override rules in a preveious sheet:

var newStyles = document.createElement('link');
newStyles.rel = 'stylesheet';
newStyles.type = 'text/css';
newStyles.href = '<uri for new css file>';
document.getElementsByTagName('head')[0].appendChild(newStyles);

You can look for the rules you want to change in the existing style
sheets and modify them.

Some combination of the above should cover your requirements. If not,
post again with what you've got so far.
 
R

RobG

Does anyone have any useful advice on how to access a different css in
a popup window ?

You can remove all current style sheets:

  var sheets = document.getElementsByTagName('link');
  var i = sheets.length;
  while (i--) {
    sheets.parentNode.removeChild(sheets);
  }


That will remove all link elements, you may want to remove only those
wehre rel=="stylesheet".

<URL: http://www.w3.org/TR/html401/types.html#type-links >
 
T

Thomas 'PointedEars' Lahn

RobG said:
Can I use javascript to access a different CSS file in the popup
window ?
The CSS file with then use display:none to hide the banner, side
navigation, etc.

Does anyone have any useful advice on how to access a different css in
a popup window ?

You can remove all current style sheets:

var sheets = document.getElementsByTagName('link');
var i = sheets.length;
while (i--) {
sheets.parentNode.removeChild(sheets);
}


That will remove all link elements, you may want to remove only those
wehre rel=="stylesheet".


Better yet, link[rel~="stylesheet"], given that …

… the `rel' attribute value may be a whitespace-separated list:

var styleSheets = document.querySelectorAll('link[rel~="stylesheet"]');
for (var i = sheets.length; i--;)
{
var styleSheet = styleSheets;
styleSheet.parentNode.removeChild(styleSheet);
}

See also <http://www.w3.org/TR/selectors-api/>.

Ceterum censeo jQuery esse delendam.


PointedEars
 
G

Garrett Smith

Does anyone have any useful advice on how to access a different css in
a popup window ?
Popup windows suck for a few significant reasons. They don't always work
and when they do, the user's browser may be configured so that the
"popup" opens in a new tab, possibly behind the current document (and so
not focused).

Edit the source code of the document that gets loaded in the "popup"
using your text editor and add a stylesheet to the head of that document.

Example:
<link rel="stylesheet" type="text/css" href="popup.css">

Your CMS should probably allow for adding a page-specific stylesheet.
You might need to read the documentation to figure out how to do that.
If it is not possible to do that, then that's a shortcoming you may want
to consider making different choice of CMS.
 
G

Garrett Smith

var sheets = document.getElementsByTagName('link');
var i = sheets.length;
while (i--) {
sheets.parentNode.removeChild(sheets);
}


That will remove all link elements, you may want to remove only those
wehre rel=="stylesheet".

That code does account for inline styleSheets.

Disabling does, and it is easier.
document.styleSheets[0].disabled = true;

Though the best way is editing the source code or reconfiguring the CMS
to have a specific page that excludes the stylesheet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top