473,835 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert embedded stylesheet as block?

I'm hoping someone can explain this and give a tip what I'm doing wrong.

This doesn't work (simplified for readability):

<style type="text/css">
<SCRIPT TYPE='text/javascript' LANGUAGE='JavaS cript'>
if ( navigator.platf orm.substring(0 ,3).toLowerCase () == 'win')
document.write( 'body { font-family: Arial} ')
else document.write( 'body {font-family: Gadget } ')
</SCRIPT>
</style>

But this does:

<SCRIPT TYPE='text/javascript' LANGUAGE='JavaS cript'>
if ( navigator.platf orm.substring(0 ,3).toLowerCase () == 'win')
document.write( '<style type="text/css"> \n' +
'body{ font-family: Arial} \n' +
'</style>')
else document.write( '<style type="text/css"> \n' +
'body { font-family: Gadget } \n' +
'</style>')
</SCRIPT>

I've tried to write style text common to both if/else's in the HTML but it
won't work. Why is this? Does JS act differently inside the style tags?

-- Gnarlie
http://www.Gnarlodious.com

Jul 23 '05 #1
2 1418
Ivo
"Gnarlodiou s" wrote
This doesn't work (simplified for readability):

<style type="text/css">
<SCRIPT TYPE='text/javascript' LANGUAGE='JavaS cript'>
if ( navigator.platf orm.substring(0 ,3).toLowerCase () == 'win')
document.write( 'body { font-family: Arial} ')
else document.write( 'body {font-family: Gadget } ')
</SCRIPT>
</style>

But this does:
<SCRIPT TYPE='text/javascript'>
var font = ( navigator.platf orm.substring(0 ,3).toLowerCase () == 'win') ?
'Arial' : 'Gadget';
document.write(
'<style type="text/css"> \n' +
'body{ font-family: '+font+ ' } \n' +
'</style>'
);
</SCRIPT>
I've tried to write style text common to both if/else's in the HTML but it
won't work. Why is this? Does JS act differently inside the style tags?


JS does not act at all inside style tags. Inside style tags only style rules
make sense. It is a pity that we cannot test directly for the presence of
certain fonts on user's system, but why don't you simply write
body{ font-family: Gadget, Arial, sans-serif; }
so that the next is used if the first does not exist?
HTH
Ivo

Jul 23 '05 #2
Entity Ivo spoke thus:
JS does not act at all inside style tags. Inside style tags only style rules
make sense. It is a pity that we cannot test directly for the presence of
certain fonts on user's system, but why don't you simply write
body{ font-family: Gadget, Arial, sans-serif; }


I guess I'll do that. Thanks for verifying what I suspected.
-- Gnarlie
http://www.Spectrumology.com
Spectrumology is the science of chaos.
Jul 23 '05 #3

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

Similar topics

4
29387
by: Wim Roffal | last post by:
On my webpage (http://www.classiccat.net/index.htm) I tried to transfer the cellpadding/spacing attributes to my stylesheet. However, somehow it doesn't work. I tried to look it up on the internet, but it seems to me that I am doing everything right, which is obviously not the case. It concerns the tables in the alphabetic part of the page. I have there a table-class "block" defined. It works fine in giving the tables their...
5
2281
by: aamirghanchi | last post by:
Hi, I have a very simple html that has a linked stylesheet. According to the style sheet both blocks of text should be displayed in the font xx-small. but only one (DIV or SPAN) at a time is displayed in this font and that would be the one that is at the end of the stylesheet file. for example if DIV selector is the last block in MyStylesheet.css then the corresponding text in the DIV tag in the html will be small font. If we swap the...
7
5210
by: pintihar | last post by:
Hi, As a follow on from an earlier post I have another question about xslt. Is it possible to create the stylsheet programatically? Is this sensible? In the first phase I needed to map element name from inbound xml to my internal elements to standardize disparate input. Now I could just create an xslt stylesheet for each possible inbound format and be done, but I think it would be powerful to be able store this mapping in a database and...
3
1384
by: RD | last post by:
My app transmits XML data file via e-mail and for now I attach both the XML data file and the corresponding style sheet. I found however that whenthe recipient double clicks on the XML file to read it, he/she can't open it that way. For some reason that escapes me, the XSL fil can't be found, although theoretically they bot are in the same folder. If user copies both XML and XSL files to another same folder for both, then he/she can read...
5
1408
by: nutsmuggler | last post by:
Hi. I am using xml to store my annotations. here is my document (a part of it): <?xml version="1.0" encoding="UTF-8"?> <text title="Finnegan's wake"> <book number="1"> <chapter number="5"> <note p="107"> script: <q>proteiform graph, polyhedron of scripture, etc</q>
0
1115
by: michga | last post by:
Hello, Using docbook 4.4, docbook-xsl 1.70.1 and fop, I've successfully used this snippet of code in a customized-layer stylesheet to insert one linebreak: <xsl:template match="processing-instruction('linebreak')"> <fo:block> </fo:block> </xsl:template>
1
5620
by: erictomlinson | last post by:
I'm dying here trying to figure this out for days. Here's the scenario: 1) External script.as file dynamically imported to loader.swf file that creates a textfield (createTextField) 2) Content for the text field should be provided by an XML file 3) Content styled by external css file 4) Fonts need to be embedded so as to apply anti-alias
3
745
by: Waruna | last post by:
Is there a way to block insert into mysql(5.0) using c api of mysql db.. i.e. say there is a table with 2 columns, one contains char other int then i want to insert 500 records at once,, as i explained below. here i declare 2 arrays of char and int to store the values i want,
1
3194
by: msarora | last post by:
I'm using SimpleTransform.java (renamed as ReceiptTransformer.java for custom use) found in xalan-j_2_7_0 samples directory for transformations in my custom application. The program compiles successfully but gives the following error during runtime: Below is the copy of the stylesheet. I'll really appreciate any help or clue in this regard.
2
1546
by: Paulson | last post by:
HI all I got a problem with my menu display.I am making a list as shown below in one of my aspx pages. And added a stylesheet in CSS for it. This is not working in IE but not in Mozilla Firefox it is working. Can anyone please help me with this? Just after the page html I pasted my CSS stylesheet code also. __________________________________________________________________
0
10812
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10523
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10235
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9346
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7766
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5638
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5804
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3089
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.