Include JavaScript code within external CSS files 
Author Message
 Include JavaScript code within external CSS files

Is there a way to include JavaScript code within external CSS files?

Thanks,

Kevin



Thu, 29 Jan 2004 07:11:07 GMT  
 Include JavaScript code within external CSS files
No.  The two types of files are read differently.  CSS files are embedded
with the <link> tag, like this (pardon my xhtml):
<link href="style.css" rel=stylesheet type="text/css" />
Whereas JavaScript/JScript external files are embedded with the <SCRIPT>
tag.
<script language="javascript" src="myscript.js" />

Sorry.

Regards,

Robert A. Paveza


Quote:
> Is there a way to include JavaScript code within external CSS files?

> Thanks,

> Kevin



Thu, 29 Jan 2004 09:42:52 GMT  
 Include JavaScript code within external CSS files
Robert,

How about a way within the CSS file to access the JS.  Can I add the
JavaScript call <script language="JavaScript" src="myscript.js"> into the
code of the CSS file.

There is a reason I am trying to do it this way.  A site that I am adding a
profile of mine to will not allow JavaScript.  I had tried the <script
language="JavaScript" src="external.js">, however it caught my attempt and
blocked it.  I was able to add CSS via the <link type="text/css"
rel="stylesheet" href="external.css"> link.  My thinking is that if I am able
to add the JS call within the CSS file I could bypass their script block to
do the trick.

Any other ideas?

Thanks,

Kevin

Quote:

> No.  The two types of files are read differently.  CSS files are embedded
> with the <link> tag, like this (pardon my xhtml):
> <link href="style.css" rel=stylesheet type="text/css" />
> Whereas JavaScript/JScript external files are embedded with the <SCRIPT>
> tag.
> <script language="javascript" src="myscript.js" />

> Sorry.

> Regards,

> Robert A. Paveza

> ----- Original Message -----

> Newsgroups: microsoft.public.scripting.jscript
> Sent: Saturday, August 11, 2001 16:11
> Subject: Include JavaScript code within external CSS files

> > Is there a way to include JavaScript code within external CSS files?

> > Thanks,

> > Kevin



Thu, 29 Jan 2004 14:50:10 GMT  
 Include JavaScript code within external CSS files


Quote:
> Robert,
> There is a reason I am trying to do it this way.  A site that I am
adding a
> profile of mine to will not allow JavaScript.

Then why are you trying, their terms and conditions for use are also I'm
sure explicit on javascript not being allowed.  Don't add your profile to
them if it requires javascript, or add one without.

expression is likely your friend though...

Jim.



Fri, 30 Jan 2004 21:06:06 GMT  
 Include JavaScript code within external CSS files

Quote:

> ...A site that I am adding a profile of mine to will not allow
> JavaScript...My thinking is that if I am able to add the JS call
> within the CSS file I could bypass their script block to do the
> trick.

> Any other ideas?

Obtain permission to use JavaScript. Or be creative with a hidden IFRAME and an external source.

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use of this email address
implies consent to these terms.



Sat, 31 Jan 2004 00:56:00 GMT  
 Include JavaScript code within external CSS files
If you are willing to limit your site to IE browsers you can use HTML
Components (HTC). These are defined in an xml file with the extension .htc
and linked to elements via their CSS class.

Read about HTC's (may wrap):
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/be...

Hope that helps.

Matt


Quote:
> Is there a way to include JavaScript code within external CSS files?

> Thanks,

> Kevin



Sat, 31 Jan 2004 01:40:12 GMT  
 Include JavaScript code within external CSS files
Dave,

Thanks for your reply!  I worked on what you suggested and then posted this question pertaining to
that:

Is there any way to code an iframe tag in IE to output the HTML into the parent HTML file without the
frame <textbox> surrounding the child HTML file?

In the meantime I figured out how to do what I wanted to...

My original iframe HTML tag was:

<iframe width='681' height='1631' src='profile.html'>
</iframe>

Adding frameborder='0' to the iframe tag attributes removes the 'textbox' look to the inner HTML
iframe!

Additionally, this resolves the issue for NN browsers as well as IE:

<html>
<head>
</head>
<body>
<iframe frameborder='0' width='681' height='1631' src='profile.html'>
</iframe>
<layer top='113' left='13' width='681' height='1631' scrolling='yes' src='profile.html'>
</layer>
</body>
</html>

Thanks again for your help,

Kevin

Quote:


> > ...A site that I am adding a profile of mine to will not allow
> > JavaScript...My thinking is that if I am able to add the JS call
> > within the CSS file I could bypass their script block to do the
> > trick.

> > Any other ideas?

> Obtain permission to use JavaScript. Or be creative with a hidden IFRAME and an external source.

> --
> Dave Anderson

> Unsolicited commercial email will be read at a cost of $500 per message. Use of this email address
> implies consent to these terms.



Mon, 02 Feb 2004 14:27:41 GMT  
 Include JavaScript code within external CSS files

Quote:

> Thanks for your reply! I worked on what you suggested and then posted this
> question pertaining to that:

> Is there any way to code an iframe tag in IE to output the HTML into the
> parent HTML file without the frame <textbox> surrounding the child HTML file?

First of all, this will take care of the border:

    <IFRAME STYLE="visibility:hidden"></IFRAME>

Then define and label a container in the parent document, along with a GP function for grabbing
object references by name:

    <DIV ID="myDiv"></DIV>
    <SCRIPT>
        function getObj(objName) {
            return document.getElementByID ? document.getElementByID(objName) :
                   document.all ? document.all[objName] : null
        }
    </SCRIPT>

Back in the child, build a string and write it to the innerHTML of your container:

    var str = "here is my text"
    parent.getObj("myDiv").innerHTML = str

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use of this email address
implies consent to these terms.



Mon, 02 Feb 2004 20:29:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Can I use an external CSS file?

2. Include JavaScript file in another include file

3. Script Encoder - Encrypted Includes within Unencrypted Code?

4. Including a file within a jscript file

5. Import/Include jscript file within a jscript file

6. Accessing VB code within Javascript

7. Accessing VB code within Javascript

8. Including an external .js file via JScript

9. TypeLib or including external files

10. Include a external file

11. TypeLib or including external files

12. WSH 2.0 include external source files - HOW?

 

 
Powered by phpBB® Forum Software