views:

88

answers:

2

Hi everyone, I get a script from a website to put it into my website, but the font color is not what I want.

The script is:

<script language="javascript" src="http://www.parstools.net/calendar/?type=2"&gt;&lt;/script&gt;

and now I want to change the font color of it. What should I do?

I would really appreciate your help, thanks.

+3  A: 

Examining the source of that script, it is simply writing an anchor link with document.write():

document.write("<a href='http://www.ParsTools.com/'&gt;1389/1/31&lt;/a&gt;");     

You may want to include that script inside a <div>, and then style the anchor links within that <div> using CSS:

<div id="calendar">
   <script src="http://www.parstools.net/calendar/?type=2"&gt;&lt;/script&gt;
</div>

Then you should also add the following CSS class definition:

div#calendar a {
    color: red;
}

The following is a full example:

<!DOCTYPE html>
<html> 
  <head> 
    <title>Simple Demo</title> 

    <style type="text/css">
       div#calendar a {
          color: red;
       }
    </style>

  </head> 
  <body> 

    <div id="calendar">
       <script src="http://www.parstools.net/calendar/?type=2"&gt;&lt;/script&gt;
    </div>        

  </body> 
</html>
Daniel Vassallo
Thanks for you asnwer Mr. Vassallo, it does work. thanks again.
Sohail
and one more question about it, actually script works fine, but it has a hyperlink to the source website (parstools.net), how can I disable the hyperlink in it?
Sohail
@user320946: That is not as easy. You may want to post another question on that.
Daniel Vassallo
A: 

I assume you want to change the font colour of the HTML code produced by the script? If so, just use normal CSS in your external stylesheet and it will apply to the added content.

For example, if you want to make the text inside the element myElement a nice blue colour:

#myElement {
    font-color: #0099FF;
}

If the script is not your own, then you will want to analyse the code produced by it to work out which elements you need to style in order to change the colour of the text. Many external scripts that you embed in your website contain inline CSS rules, meaning that you will have to override many elements in your external CSS stylesheet to change simple things like text colour. You may also have to add !important to the end of your CSS rule in order to override the inline styling:

#myElement {
    font-color: #0099FF !important;
}
Steve Harrison