Click to See Complete Forum and Search --> : How to insert (txt, etc) files into HTML


venkusalo
04-26-2003, 05:28 AM
I suspect it is an easy matter once one knows :)
I have an encrypted .js file that I want to load, or embed, or insert into a web page.
How do I call this?
The best I have to date is:
<script>
location.replace("script/***.js");
</script>
But this (obviously) replaces. How to get that ol .js INTO the page?

Charles
04-26-2003, 05:39 AM
<script src="some.js" type="text/javascript" ></script>

And see http://www.w3.org/TR/html4/interact/scripts.html.

venkusalo
04-26-2003, 05:51 AM
Thanks for such a speedy reply Charles.
Yes, that is the standard script but what I have is an encrypted file that 'unpacks' when it is written. So, if I just open the file itself in a browser it writes the script to that page.

What i am trying to do is just write the file to the page.
document.write writes the 'content' of the .js but I am trying to load the file itself - which is self writing.

Make sense?

pyro
04-26-2003, 10:23 AM
If you want what I think you want, you will need some server side language. I know how to do it in PHP and SSI.

PHP (.php)
<?PHP
include ("yourfile.txt");
?>

SSI (.shtml)
<!--#include file="yourfile.txt"-->

venkusalo
04-26-2003, 05:28 PM
Dear Pyro,
my knowledge of PHP and such is pretty scant

- & anyone

I am enjoying the challenge - each one adds to my limited knowledge - but, I wonder if this enctyption idea is going to cause more trouble than the protection it will provide.

I have added a zip file [insert.zip - 4k] with a few comments.

thanks - VK

venkusalo
04-26-2003, 07:22 PM
Dear Dave,

Thanks, but it kind of puts a closed end on the thread, n'est pas?
Is the en-de crypt so easy? Or is it that once the code has been written/displayed it is normal - therefore right clickable, view sourceable?

In IE, location.replace displays the log-in form and view source reveals the still encrypted file. But... NS no likee.

I bumble about my merry way and am happy to drop this approach. Do you have any alternative suggestions?

venkusalo
04-26-2003, 08:59 PM
Dear Dave,

Live and learn...
So, it bends and stretches but can't be relied on for protection huh?

Thanks for the codelet.

I will continue to fish - perhaps in a different pond - VK

venkusalo
04-27-2003, 12:02 AM
Dear Dave,

No, not at all.
It is great fun - I poke about here and there and learn a bit along the way. Most of my web work/play is work and play.

I very much appreciate people like yourself who take the time to ponder the mutterings of digital neophites such as myself. thanks - VK