473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Changing CSS styles with javascript

Hi,

I know nothing about javascript, but quite a lot about regulat html and
CSS.
Have bumped into a problem that people in this fine congregation
perhaps can help me with.

I'm making a webshop. When user eventually ends up at the credit card
processor's secure pages, the styles are quite different from the
actual site's. I have managed to change some basics through a control
panel, but not everything that needs to be changed to make it look OK.

The pages are generated dynamically. In the head section, there's the
CSS which I cannot access/change. Many tags also have inline styles
(e.g. <span style="font-family: Times...blah blah">

What I'm trying to do is to...

1) Add styles AFTER the body tag (I can do that, but not in the head)
2) Use a javascript, placed in the body, that substitutes the classes
and styles in the head to the corresponding styles defined in the body.

I have Googled a lot, and eventually found this page:
http://www.onlinetools.org/articles/...eparation.html
which I think is addressing a similar (or the same?) issue.

But if someone can point to a tutorial or some help for me who is a
complete ignoramus about javascript, and that will help me achieve what
I want, that would be highly appreciated.

Cheers,

Sep 13 '05 #1
12 2530
ASM
da********@gmail.com wrote:
Hi,

I know nothing about javascript, but quite a lot about regulat html and
CSS.
Have bumped into a problem that people in this fine congregation
perhaps can help me with.

I'm making a webshop. When user eventually ends up at the credit card
processor's secure pages, the styles are quite different from the
actual site's. I have managed to change some basics through a control
panel, but not everything that needs to be changed to make it look OK.
Wouldn't it be a good idea to keep differet design of secured page ?
That buyer well understand he is on a really different part of site ?
The pages are generated dynamically. In the head section, there's the
CSS which I cannot access/change. Many tags also have inline styles
(e.g. <span style="font-family: Times...blah blah">

What I'm trying to do is to...

1) Add styles AFTER the body tag (I can do that, but not in the head)
so ... no more problem, no ?
2) Use a javascript, placed in the body, that substitutes the classes
and styles in the head to the corresponding styles defined in the body.

But if someone can point to a tutorial or some help for me who is a
complete ignoramus about javascript, and that will help me achieve what
I want, that would be highly appreciated.


on my idea, it is too difficult and needs to much heavy code

i.e. resetting TD

var T = document.getElementsByTagName('TD');
for(var i=0;i<T.length;i++) {
T[i].className = '';
var D = T[i].style;
D.fontFamily = 'arial,geneva,helvetica,verdana';
D.fontSize = '0.9em';
D.color = 'navy';
D.fontVariant = 'small-caps';
// etc ... etc ...
}

while in css

td, td.foo {
font : "arial,geneva,helvetica,verdana" 0.9em navy small-caps;
}


--
Stephane Moriaux et son [moins] vieux Mac
Sep 13 '05 #2
Hi Stephane,

Thanks for reply.
The user will see a HUGE headline when he's entering the secure pages
telling him where he is.
But it seems as if I haven't explained well, or that you are
misunderstanding:

Yes, it is of course easier to do in CSS. But that's the problem: I can
NOT use pure CSS. I MUST have a javascript to "force" my styles into
existing (and dynamically generated) code.

And I don't have a clue how to do that, or if it's even possible. But
as I wrote, this page:
http://www.onlinetools.org/articles/...eparation.html
seems to deal with it and, if so, might be a hint about what I think I
need.

Cheers,
Dan

Sep 13 '05 #3
http://www.onlinetools.org/articles/...eparation.html
seems to deal with it and, if so, might be a hint about what I think I
need.


it would seem that you have answered your own question !!
Sep 13 '05 #4
da********@gmail.com wrote:
Hi,

I know nothing about javascript, but quite a lot about regulat html and
CSS.
Have bumped into a problem that people in this fine congregation
perhaps can help me with.

I'm making a webshop. When user eventually ends up at the credit card
processor's secure pages, the styles are quite different from the
actual site's. I have managed to change some basics through a control
panel, but not everything that needs to be changed to make it look OK.

The pages are generated dynamically. In the head section, there's the
CSS which I cannot access/change. Many tags also have inline styles
(e.g. <span style="font-family: Times...blah blah">

What I'm trying to do is to...

1) Add styles AFTER the body tag (I can do that, but not in the head)
2) Use a javascript, placed in the body, that substitutes the classes
and styles in the head to the corresponding styles defined in the body.

I have Googled a lot, and eventually found this page:
http://www.onlinetools.org/articles/...eparation.html
which I think is addressing a similar (or the same?) issue.

But if someone can point to a tutorial or some help for me who is a
complete ignoramus about javascript, and that will help me achieve what
I want, that would be highly appreciated.


As noted, you've answered your own question.
Email me, no BOGUS, old friend.
Mick
Sep 13 '05 #5
ASM
da********@gmail.com wrote:
Hi Stephane,

Thanks for reply.
The user will see a HUGE headline when he's entering the secure pages
telling him where he is.
But it seems as if I haven't explained well, or that you are
misunderstanding:

Yes, it is of course easier to do in CSS. But that's the problem: I can
NOT use pure CSS. I MUST have a javascript to "force" my styles into
existing (and dynamically generated) code.
OK, I do understand you want to add code to a page which isn't yours.
This page probably is on an other domain :
a normal browser will refuse to do something to this page.
This page is securized : don't believe you can acceed to the code, no?
And I don't have a clue how to do that, or if it's even possible. But
as I wrote, this page:
http://www.onlinetools.org/articles/...eparation.html
seems to deal with it and, if so, might be a hint about what I think I
need.


except example they give
http://www.onlinetools.org/articles/...eparation.html
has everything hard coded (any external action)

if the secured page is opened in a frame
perhaps could you try to modify it ? :

function collapse() {
if(!parent.frame_1.document.createTextNode){return ;}
var p=parent.frame_1.document.createElement('p');
etc ...

name of frame with secured page = 'frame_1'
acces to this page = parent.frame_1.document

and don't forget last line of this demo :
parent.frame_1.onload=collapse;

Have a look here this little demo if that can help you :
http://perso.wanadoo.fr/stephane.mor...i_clone_popup/
in french ... goal is to copy an element (a div and its children)
several times in a popup from mother window
The only 1st cloned element has some of its children changed
1st violet button = launch the trick
2nd violet button = download demo

--
Stephane Moriaux et son [moins] vieux Mac
Sep 13 '05 #6
da********@gmail.com wrote:
I'm making a webshop. When user eventually ends up at the credit card
processor's secure pages, the styles are quite different from the
actual site's. I have managed to change some basics through a control
panel, but not everything that needs to be changed to make it look OK.

The pages are generated dynamically. In the head section, there's the
CSS which I cannot access/change. Many tags also have inline styles
(e.g. <span style="font-family: Times...blah blah">

What I'm trying to do is to...

1) Add styles AFTER the body tag (I can do that, but not in the head)
2) Use a javascript, placed in the body, that substitutes the classes
and styles in the head to the corresponding styles defined in the body.

If one can indeed inject some of their own content into this page
delivery , you should be able to do what ever you like to the styles.

Heres a demo that loads new CSS stylesheet files on the fly.
It can be raided for all the basic components to beat on yourpage.
http://www.drclue.net/projects/jsDHT.../OperaCSS.html

Heres another that tears a page apart and translates it to another form
http://www.drclue.net/projects/jsDHT.../HTML2CSS.html

--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
Sep 14 '05 #7
Hi Stephane,

Hmmm.. you are assuming things I haven't even mentioned and reasoning
from that standpoint. Perhaps I'm still not explaining well enough:

It's not two domains involved, but one: the credit card processor's
domain. I am able to add a header and footer to all dynamically
generated pages. The header I can add starts from <body> and own.
That's where I intend to place the substitute styles. W3C don't like
it, which is irrelevant since every browser will read the styles
anyway.

To clarify further, here's a mockup example:

<html>
<head>
<!------ original styles below ----->
<styles>
..1 {blah blah}
#2 { blah blah}
td {blah blah}
</styles>
<!------ end original styles ----->
</head>
Code is generated dynamically. But I can add code from here and
downward. The code I add will be placed in every page.
<body>
<!------ substitute styles below ----->
<styles>
..3 {blah blah}
#4 {blah blah}
..5 {blah blah}
</styles>
<!------ end substitute styles ----->

<!----- elements below ----->
<p class="1">blah blah</p>
<div id="2">blah blah</div>
<td>blah blah</td>
<span style="font-family: Times, serif"> blah blah</span>
<!----- end elements ----->

<!----- javascript below ----->
<script type="javascript">
find: class="1", replace with: class="3"
find: id="2", replace with: id="4"
find: td, replace with: class="5"
find: style="font-family: Times, serif", replace with:
style="font-family: Verdana, sans-serif"
</script>
<!----- end javascript ----->
</body>
</html>

Sep 14 '05 #8
Hi Clue,

With my limited knowledge about javascript, it seems to me as if both
examples require code in the head section, no? If so, I'm sorry to say
that I can't use neither.

Cheers,
Dan

Sep 14 '05 #9
Hullo Mick!

Well, as I don 't know squat about javascript, I tried to make you
confirm that the script actually is doing what I think. I suppose, by
the replies, that it does, even if I haven't seen a clear confirmation.

I've mailed you off-list!

Cheers,
Dan

Sep 14 '05 #10
da********@gmail.com wrote:
With my limited knowledge about javascript, it seems to me as if both
examples require code in the head section, no? If so, I'm sorry to say
that I can't use neither.


You can do this approach without placing any code
in the <head></head> at all, as long as you can get some of your content
delivered inside that page delivery.
--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
Sep 14 '05 #11
Dr Clue wrote in message news:Fd*****************@newsread2.news.pas.earthl ink.net...
[...]
Heres a demo that loads new CSS stylesheet files on the fly.
It can be raided for all the basic components to beat on yourpage.
http://www.drclue.net/projects/jsDHT.../OperaCSS.html

Heres another that tears a page apart and translates it to another form
http://www.drclue.net/projects/jsDHT.../HTML2CSS.html


Your examples (and work) are impressive, I have a small remark/comment
on the HTML2CSS.html page(s)

I loaded "lesson 4" and realized how horribly mis<tag>ged the page was.
I don't know if it's on purpose or if you took the pages as they were
and didn't validate them.
example 1:

<body bgcolor="#ffffff">
<p>
<table border="0" width="100%">
<tbody>
[...]

</tbody></table>
</p><p></p>
^^^
endtag without opening tag. According to the DTDs the P element cannot contain
table elements.
<!ELEMENT P - O (%inline;)* -- paragraph -->
<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">
<!ENTITY % fontstyle "TT | I | B | BIG | SMALL">
<!ENTITY % phrase "EM | STRONG | DFN | CODE | SAMP | KBD | VAR | CITE | ABBR | ACRONYM" >
<!ENTITY % special "A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO">
<!ENTITY % formctrl "INPUT | SELECT | TEXTAREA | LABEL | BUTTON">
in other words, the <p> tag was closed when before <table>
and now </p> is there all by itself.

The same applies to the following (<h2> within <h5>):

<h5>
<center>
<h2><font face="Verdana, Arial, Helvetica, sans-serif">Lesson 4 -- Tools to
Use in Selecting Materials</font> </h2>
</center>
</h5>

<!ENTITY % heading "H1|H2|H3|H4|H5|H6">
<!ELEMENT (%heading;) - - (%inline;)* -- heading -->
<!ENTITY % inline "#PCDATA | %fontstyle; | %phrase; | %special; | %formctrl;">
<!ENTITY % fontstyle "TT | I | B | BIG | SMALL">
<!ENTITY % phrase "EM | STRONG | DFN | CODE | SAMP | KBD | VAR | CITE | ABBR | ACRONYM" >
<!ENTITY % special "A | IMG | OBJECT | BR | SCRIPT | MAP | Q | SUB | SUP | SPAN | BDO">
<!ENTITY % formctrl "INPUT | SELECT | TEXTAREA | LABEL | BUTTON">

only here the closing tag is mandatory. You cannot nest certain block elements.
Sep 15 '05 #12
Robi wrote:
Dr Clue wrote in message news:Fd*****************@newsread2.news.pas.earthl ink.net...
Heres a demo that loads new CSS stylesheet files on the fly.
It can be raided for all the basic components to beat on yourpage.
http://www.drclue.net/projects/jsDHT.../OperaCSS.html

Heres another that tears a page apart and translates it to another form
http://www.drclue.net/projects/jsDHT.../HTML2CSS.html

Your examples (and work) are impressive, I have a small remark/comment
on the HTML2CSS.html page(s)

I loaded "lesson 4" and realized how horribly mis<tag>ged the page was.
I don't know if it's on purpose or if you took the pages as they were
and didn't validate them.


The purpose of the tool was to aid someone converting nearly a thousand
yucky pages of tag soup, so the ditty was developed in one evening
to work with the pages as they existed, and therefore w/o the benefit
of any validation.


--
--.
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=-- C++,HTML, CSS,Javascript
--=<> http://resume.drclue.net <>=-- AJAX, SOAP, XML, HTTP
--=<> http://www.drclue.net <>=-- SERVLETS,TCP/IP, SQL
--.
Sep 15 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jeff Thies | last post by:
I have a number of elements of "some-class". I'd like to change the styles of some-class: from ..some-class{color: red; display: block} to
5
by: Andrew Poulos | last post by:
I'm trying to change a style in a stylesheet. The following code works in FF, MZ, and IE6 but IE 5 gives the error of "invalid procedure call or argument": var oStyleSheet =...
5
by: T. Wong | last post by:
I want to have a single CSS style sheet control the look of my whole asp.net application but I need to set the values in this CSS from code in the start page as the CSS values will be stored in a...
8
by: Bosconian | last post by:
I have two multiple select inputs. Initially the first contains a bunch of items and the second is empty. Using a common method, I move items back and forth by double clicking on them. This...
4
by: Sam Carleton | last post by:
How do I change the CSS colors via JavaScript DOM? Let me explain... I am working on a Windows application (in C#) that displays some HTML. In one place the HTML is a status window. What happens...
10
by: sbaker8688 | last post by:
My God, how on earth do you use javacript to change the text color of an input element, and have it work with IE??? I've tried numerous solutions. All of them work on browsers such as Mozilla. ...
5
by: Dinsdale | last post by:
Without using CSS styles or linked stylesheets, I need to apply formatting to text links that use rollover effects. I can NOT get the underline to show using this technique: <A...
4
by: splounx | last post by:
Hi there, I am a relative CSS & JavaScript novice and I have a particular problem that is beyond my level of knowledge so I thought I'd tap the collective wisdom of this group. I would like...
6
by: Rafaell | last post by:
Hi, everyone! I hope you guys can help me. I´m working on a website which deals with 4 different css styles. Once in the Homepage, the user can choose one link out of four to enter the site....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.